Skip to content
Advertisement

How do I consume given dependency with multiple classifiers and extensions in Gradle?

I am trying to figure out how to consume the *.{so,jar} files listed in https://repo1.maven.org/maven2/org/sosy-lab/javasmt-solver-z3/4.8.10/ (see also the corresponding entry on mvnrepository.com) as exemplified (with Maven) here, with Gradle 6.8.3 and a Kotlin configuration. Relevant parts of my code are

repositories {
    jcenter()
    mavenCentral()
}

dependencies {
    implementation(group = "org.sosy-lab", name = "javasmt-solver-z3", version = "4.8.10", classifier = "com.microsoft.z3", ext = "jar")
    implementation(group = "org.sosy-lab", name = "javasmt-solver-z3", version = "4.8.10", classifier = "libz3", ext = "so")
    implementation(group = "org.sosy-lab", name = "javasmt-solver-z3", version = "4.8.10", classifier = "libz3java", ext = "so")
}

The output I get is

Could not resolve org.sosy-lab:javasmt-solver-z3:4.8.10.

I already tried (1.) commenting out any two out of the three dependencies, (2.) reordering the repositories. The output is the same. What am I doing wrong here?

Advertisement

Answer

Gradle searches for a pom.xml per default and it fails because some of the JavaSMT artifacts don’t have any (or no useful ones). You can however tell Gradle to search for artifacts directly. To do this you need to add a metadataSource to your repo like so:

repositories {
    jcenter()
    mavenCentral {
        metadataSources {
            artifact()
        }
    }
}
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement