Gradle 7.4.2在Groovy和Java 17上失败



我们目前有一个项目,使用

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$

效果很好。现在我需要将项目更新为Java 17,因此我将项目更改为

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$

但是我一直得到

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$ 

所以,不知何故,我的gradle仍然在使用Groovy-2.5.13,而它应该使用Groovy-3.0.9。

有没有人有一个想法,我可以做些什么来切换Gradle-7.4.2到Groovy-3.0.9?

提前感谢。kniffte

我终于能够构建这个项目了。一段时间后,Gradle接受了这些更改并成功构建。改变需要:

  • gradle/包装/gradle-wrapper。更新distributionUrl到7.4.2版本
  • 更新org。spock-*到2.2-M1-groovy-4.0版本

我仍然不明白,确切的原因是什么,但它现在正在做:万岁!

不管怎样,还是谢谢你。kniffte

最新更新