Has anyone seen an error like this before? This o...
# gradle
c
Has anyone seen an error like this before? This only occurs on GitHub Actions - it works fine locally. (sample failing build: https://github.com/kotest/kotest/runs/7494593098?check_suite_focus=true#step:5:53)
Copy code
Could not determine the dependencies of task ':kotest-framework:kotest-framework-multiplatform-plugin-gradle:test'.
> Could not resolve all task dependencies for configuration ':kotest-framework:kotest-framework-multiplatform-plugin-gradle:testRuntimeClasspath'.
   > Could not resolve project :kotest-assertions:kotest-assertions-core.
     Required by:
         project :kotest-framework:kotest-framework-multiplatform-plugin-gradle
      > The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, preferably optimized for standard JVMs, 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 :kotest-assertions:kotest-assertions-core:
          - jvmRuntimeElements
          - runtimeElements
(full error in thread)
A similar error is generated for each project the
kotest-framework-multiplatform-plugin-gradle
project references.
Full error for a single project reference:
v
A wild guess would be, that you maybe locally use a different Java version and because of that have different results. If so, you should consider using JVM toolchains feature to mitigate that. And if you can, maybe update to Gradle 7.5, the output for such errors greatly improved iirc.
☝️ 1
c
Interestingly, I get a similar error locally if I try to use
includeBuild
to include the Kotest project into another project.
A wild guess would be, that you maybe locally use a different Java version and because of that have different results. If so, you should consider using JVM toolchains feature to mitigate that.
You might be on to something here - the build on GitHub Actions is using Java 8, whereas I have Java 18 installed locally. But this doesn’t explain the behaviour with
includeBuild
locally…
And if you can, maybe update to Gradle 7.5, the output for such errors greatly improved iirc.
Just tried this, the output is the same either way. The Gradle release notes seem to suggest the improvements are for tasks such as
dependencyInsight
, but I don’t get output matching the example in the release notes 🤔 Looks like the improved output is only shown when dependencies can be resolved successfully, not when a failure occurs.
Running
./gradlew :kotest-framework:kotest-framework-multiplatform-plugin-gradle:dependencyInsight --configuration testRuntimeClasspath --dependency :kotest-assertions:kotest-assertions-core
locally shows that Gradle is selecting
jvmRuntimeElements
.
Your suggestion about the JVM versions was the clue I needed - turned out the Gradle plugin project had Java version compatibility configured in its `build.gradle.kts`:
Copy code
java {
   sourceCompatibility = JavaVersion.VERSION_1_8
   targetCompatibility = JavaVersion.VERSION_1_8
}
…and the projects it was trying to consume did not have the same configuration. Adding that same
java { … }
block to their Gradle config was enough to fix the issue. Thanks for your help @Vampire!
👌 2
v
Looks like the improved output is only shown when dependencies can be resolved successfully, not when a failure occurs.
Oh, bad. 😞 Then it was probably more hope that it improved too, sorry.
e
@charleskorn I think I was looking into the same issue here: https://kotlinlang.slack.com/archives/C19FD9681/p1656541828249869