Use a Groovy 4 compatible Spock

MSAL

Gradle 9 compiles Groovy with Groovy 4, where Gradle 8 used Groovy 3. A Gradle plugin project that takes Groovy from Gradle rather than declaring its own, which is what java-gradle-plugin projects do, then compiles its Spock specifications against Groovy 4, and a Spock built for an earlier Groovy refuses to run: "The Spock compiler plugin cannot execute because Spock 2.0.0-groovy-3.0 is not compatible with Groovy 4.0.33". This recipe switches every org.spockframework dependency of such a project to the Groovy 4 variant of the same Spock version, or to 2.5-groovy-4.0 where that version has no Groovy 4 variant, which is every Spock before 2.2. A project that declares its own Groovy is left alone, since its Spock matches that Groovy and not Gradle's. Spock 1.x is left alone as well: it has no Groovy 4 variant at all, and moving to 2.x is a migration of the tests rather than of the build, since Spock 2 runs on the JUnit Platform. A version written as a property or an interpolated string is left alone, because the variant cannot be read from it. See the Gradle upgrade guide.

org.openrewrite.gradle.migrate.artifacts.UseGroovy4CompatibleSpock
mod run . --recipe=org.openrewrite.gradle.migrate.artifacts.UseGroovy4CompatibleSpock

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.