gradlejava-17groovy-3.0

Gradle 7.4.2 fails on Groovy and Java 17


we're currently having a project, using

stsc@linex014:~/IdeaProjects/gradle-app$ ./gradlew  -v

------------------------------------------------------------
Gradle 6.4.1
------------------------------------------------------------

Build time:   2020-05-15 19:43:40 UTC
Revision:     1a04183c502614b5c80e33d603074e0b4a2777c5

Kotlin:       1.3.71
Groovy:       2.5.10
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          17.0.3 (Eclipse Adoptium 17.0.3+7)
OS:           Linux 5.13.0-44-generic amd64

stsc@linex014:~/IdeaProjects/gradle-app$ java -version
openjdk version "11.0.15" 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1)
OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1, mixed mode, sharing)
stsc@linex014:~/IdeaProjects/gradle-app$ cat build.gradle
[...]
sourceCompatibility = 11
dependencies {
    testImplementation ('org.spockframework:spock-core:2.2-M1-groovy-2.5')
    testImplementation ('org.spockframework:spock-spring:2.2-M1-groovy-2.5')
}
[...]
stsc@linex014:~/IdeaProjects/gradle-app$

Which works fine. Now I need to update the project to Java 17, so I changed the project to

stsc@linex014:~/IdeaProjects/gradle-app$ cat build.gradle
[...]
sourceCompatibility = 17
dependencies {
    testImplementation ('org.spockframework:spock-core:2.2-M1-groovy-3.0')
    testImplementation ('org.spockframework:spock-spring:2.2-M1-groovy-3.0')
}
[...]
stsc@linex014:~/IdeaProjects/gradle-app$ java -version
openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment Temurin-17.0.3+7 (build 17.0.3+7)
OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode, sharing)
stsc@linex014:~/IdeaProjects/gradle-app$ ./gradlew wrapper --gradle-version 7.4.2
Downloading https://services.gradle.org/distributions/gradle-7.4.2-bin.zip
...........10%...........20%...........30%...........40%...........50%...........60%...........70%...........80%...........90%...........100%

Welcome to Gradle 7.4.2!

Here are the highlights of this release:
 - Aggregated test and JaCoCo reports
 - Marking additional test source directories as tests in IntelliJ
 - Support for Adoptium JDKs in Java toolchains

For more details see https://docs.gradle.org/7.4.2/release-notes.html

Starting a Gradle Daemon, 2 stopped Daemons could not be reused, use --status for details

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.4.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 22s
1 actionable task: 1 up-to-date
stsc@linex014:~/IdeaProjects/gradle-app$ ./gradlew  -v

------------------------------------------------------------
Gradle 7.4.2
------------------------------------------------------------

Build time:   2022-03-31 15:25:29 UTC
Revision:     540473b8118064efcc264694cbcaa4b677f61041

Kotlin:       1.5.31
Groovy:       3.0.9
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          17.0.3 (Eclipse Adoptium 17.0.3+7)
OS:           Linux 5.13.0-44-generic amd64

stsc@linex014:~/IdeaProjects/gradle-app$

But I keep getting

tsc@linex014:~/IdeaProjects/gradle-app$ ./gradlew clean test --no-daemon
To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.4.2/userguide/gradle_daemon.html#sec:disabling_the_daemon.
Daemon will be stopped at the end of the build 
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

> Task :compileJava
Note: /home/stsc/IdeaProjects/gradle-app/src/main/java/com/daimler/das/config/logger/CustomHtmlLayout.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :compileTestJava
Note: /home/stsc/IdeaProjects/gradle-app/src/test/java/com/daimler/das/resttemplates/RecognizeRestTemplateTest.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :compileTestGroovy FAILED
startup failed:
Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/home/stsc/.gradle/caches/modules-2/files-2.1/org.spockframework/spock-core/2.2-M1-groovy-3.0/9886c74090213b1837bd786da8db2216b186fd62/spock-core-2.2-M1-groovy-3.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation  because of exception org.spockframework.util.IncompatibleGroovyVersionException: The Spock compiler plugin cannot execute because Spock 2.2.0-M1-groovy-3.0 is not compatible with Groovy 2.5.13. For more information (including enforce mode), see https://docs.spockframework.org (section 'Known Issues').
Spock artifact: file:/home/stsc/.gradle/caches/modules-2/files-2.1/org.spockframework/spock-core/2.2-M1-groovy-3.0/9886c74090213b1837bd786da8db2216b186fd62/spock-core-2.2-M1-groovy-3.0.jar
Groovy artifact: file:/home/stsc/.gradle/caches/modules-2/files-2.1/org.codehaus.groovy/groovy/2.5.13/ac054525fdc81cbd0bc2552b57052ebb1a93cd40/groovy-2.5.13.jar

1 error


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileTestGroovy'.
> Compilation failed; see the compiler error output for details.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.4.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 18s
7 actionable tasks: 7 executed
stsc@linex014:~/IdeaProjects/gradle-app$ 

So somehow, my gradle still is still using Groovy-2.5.13, while it should be using Groovy-3.0.9.

Does anybody have an idea, what I can do to switch Gradle-7.4.2 to Groovy-3.0.9?

Thanks in advance. kniffte


Solution

  • I've finally been able to build the project. After some time, Gradle has accepted the changes and built successfully. Changes needed:

    I still do not understand, what the exact cause was, but it is doing it now: hooray!

    Thank you anyway. kniffte