This message was deleted.
# community-support
s
This message was deleted.
s
Bonus points... how can i tell Gradle I could care less about variants? 😉
c
could you include the remainder of the error message? It has the other half (what was provided vs what was expected).
👍🏼 1
s
Even more strange it only seems to happen on our CI
The full error is -
Copy code
Could not determine the dependencies of task ':hibernate-gradle-plugin:checkstyleMain'.
> Could not resolve all task dependencies for configuration ':hibernate-gradle-plugin:compileClasspath'.
   > Could not resolve project :hibernate-core.
     Required by:
         project :hibernate-gradle-plugin
      > No matching variant of project :hibernate-core was found. The consumer was configured to find a library for use during compile-time, compatible with Java 11, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.2.1' but:
          - Variant 'apiElements' capability org.hibernate.orm:hibernate-core:6.3.0-SNAPSHOT declares a library for use during compile-time, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 20 and the consumer needed a component, compatible with Java 11
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.2.1')
          - Variant 'javadocElements' capability org.hibernate.orm:hibernate-core:6.3.0-SNAPSHOT declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.2.1')
          - Variant 'mainSourceElements' capability org.hibernate.orm:hibernate-core:6.3.0-SNAPSHOT declares a component, and its dependencies declared externally:
              - Incompatible because this component declares a component of category 'verification' and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.2.1')
                  - Doesn't say anything about its usage (required compile-time)
          - Variant 'runtimeElements' capability org.hibernate.orm:hibernate-core:6.3.0-SNAPSHOT declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 20 and the consumer needed a component, compatible with Java 11
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.2.1')
          - Variant 'sourcesElements' capability org.hibernate.orm:hibernate-core:6.3.0-SNAPSHOT declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.2.1')
          - Variant 'testResultsElementsForTest' capability org.hibernate.orm:hibernate-core:6.3.0-SNAPSHOT:
              - Incompatible because this component declares a component of category 'verification' and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them preferably in the form of class files)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.2.1')
                  - Doesn't say anything about its usage (required compile-time)
v
Incompatible because this component declares a component, compatible with Java 20 and the consumer needed a component, compatible with Java 11
👆 1
c
On your CI the code is compiled with Java 20, yet the consumer expects Java 11.
Copy code
Incompatible because this component declares a component, compatible with Java 20 and the consumer needed a component, compatible with Java 11
v
☝️
To be a bit more concrete,
org.hibernate.orm:hibernate-core:6.3.0
is compiled with target Java 20,
hibernate-gradle-plugin
requests
hibernate-core
compatible with Java 11. You could tell Gradle you don't care about variant, but that would just make it fail at runtime for trying to read Java 20 class files while running on Java 11.
Maybe you do not use JVM toolchains to build
hibernate-core
but use JVM toolchains to build
hibernate-gradle-plugin
and run Gradle with Java 20 on CI but Java 11 locally. So locally the built
hibernate-core
would be compatible with Java 11 while on CI it is only compatible with Java 20. That's why it is a good idea to decouple the JVM you use to run Gradle from the JVM that is used to build / test / run your production code by using JVM toolchains everywhere. 🙂
s
That's roughly what we do. But we need to test a number of jre/jdk combos
v
Btw. when running Gradle locally from the commandline, these error messages are much more helpful, as they are colored with red and green to highlight compatibilites and incompatibilities. Just if you run thorugh CI or IDE integration you loose this important coloring which makes the errors much more readable.
s
I have not yet been able to reproduce locally though. But I'll try running locally with Java 20
👌 1
We do try to leverage Gradle toolchains, but that feature does not allow for e.g. compiling with one version but testing with another afaict
c
it does; the test tasks can also take a toolchain, which can be separate from the compile one.
v
The min Java version of the variant is calculated / taken from the main compilation task if I remember correctly. So problems I have seen include that you for example build a multi-release JAR that is compatible with Java 8, but have Java 9+ classes in the multi-release JAR. Depending on how this is setup I already have seen that the variant then has Java 9 as compatibility, while the multi-release JAR would actually be Java 8 compatible. In such cases you need to fix the setup that produces the variant or manually override that attribute on the outgoing variant to overrule the detection that might not match your setup.
s
So it seems like this is related to GroovyCompile, or at least that is part of it
Sorted it. Thanks y'all!
👌 1
👍 1