HowTo: run the Groovy tests locally with the latest Groovy version

For those who may want to run the Groovy tests locally with the latest Groovy version and may be having problems, there have been some changes.

First, if using Groovy 4.0+, with the latest Java version, then install the latest Gradle version by setting the distributionUrl in the gradle-wrapper.properties file accordingly

distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip

The Gradle version for the Java version being used can be found at the Compatibility Matrix. Most likely, if using Groovy version 4.0+, then Java 19+ is being used.

The spock-core for Groovy version 4.0+ is now 2.4-M1-groovy-4.0 for testImplementation in the build.gradle file.

testImplementation "org.spockframework:spock-core:2.4-M1-groovy-4.0"

With Groovy version 4.0+ codehaus is now replaced by apache for the implementation, and the groovy-all is the current Groovy version.

implementation "org.apache.groovy:groovy-all:4.0.8"

dependencies {
    testImplementation "org.spockframework:spock-core:2.4-M1-groovy-4.0"
    implementation "org.apache.groovy:groovy-all:4.0.8"
}

Here is a link to all of the supported spock-core versions

I’ve only gone through this reconfiguration with the Isogram Exercise. If other exercises have issues, I’m unaware of them.

2 Likes