https://kotlinlang.org logo
Title
c

christophsturm

12/18/2020, 12:18 PM
I’m trying to use a library via
includeBuild("../nanotest")
and
testImplementation("nanotest:nanotest:0.1")
the build file of the library has this:
group = "nanotest"
version = "0.1"
and the settings file this:
rootProject.name = "nanotest"
but when i build gradle does not find it:
Could not resolve nanotest:nanotest:0.1.
Required by:
    project :
I use composite builds all the time and it just works but now i have no idea whats wrong
hmm i get this error message when i run it from the commandline:
> Could not resolve all task dependencies for configuration ':testRuntimeClasspath'.
   > Could not resolve nanotest:nanotest:0.1.
     Required by:
         project :
      > The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'. However we cannot choose between the following variants of project :nanotest:
          - compile
          - default
          - runtime
          - testCompile
          - testRuntime
        All of them match the consumer attributes:
          - Variant 'compile' capability nanotest:nanotest:0.1 declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
              - Unmatched attributes:
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its usage (required a runtime)
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :' but the consumer didn't ask for it
          - Variant 'default' capability nanotest:nanotest:0.1 declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
              - Unmatched attributes:
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its usage (required a runtime)
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :' but the consumer didn't ask for it
          - Variant 'runtime' capability nanotest:nanotest:0.1 declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
              - Unmatched attributes:
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its usage (required a runtime)
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :' but the consumer didn't ask for it
          - Variant 'testCompile' capability nanotest:nanotest:0.1 declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
              - Unmatched attributes:
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its usage (required a runtime)
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :' but the consumer didn't ask for it
          - Variant 'testRuntime' capability nanotest:nanotest:0.1 declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
              - Unmatched attributes:
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its usage (required a runtime)
                  - Provides attribute 'org.jetbrains.kotlin.localToProject' with value 'local to :' but the consumer didn't ask for it
        The following variants were also considered but didn't match the requested attributes:
          - Variant 'apiElements' capability nanotest:nanotest:0.1 declares a library, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
              - Incompatible because this component declares an API of a component compatible with Java 14 and the consumer needed a runtime of a component compatible with Java 8
          - Variant 'runtimeElements' capability nanotest:nanotest:0.1 declares a runtime of a library, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
              - Incompatible because this component declares a component compatible with Java 14 and the consumer needed a component compatible with Java 8
it seems that gradle thinks one library is for java 14 and one is for 1.8
adding this to the nanotest build fixes it:
tasks.withType<JavaCompile>() {
    sourceCompatibility = "1.8"
    targetCompatibility = "1.8"
}
it already contained this:
tasks.withType<KotlinCompile> {
    kotlinOptions.jvmTarget = "1.8"
}
and it contains no java sources