You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by ma...@apache.org on 2026/09/24 08:54:44 UTC

(grails-core) 03/03: Set the Spock Groovy version opt-out for every module

This is an automated email from the ASF dual-hosted git repository.

matrei pushed a commit to branch deps/groovy-6.0.0
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 1ab1f813452815bca356b0bf2dd0bea16e42f7e0
Author: Mattias Reichel <ma...@gmail.com>
AuthorDate: Thu Sep 24 08:22:47 2026 +0200

    Set the Spock Groovy version opt-out for every module
    
    The spring-security-ui-common test-example helper applies only the groovy
    and java-test-fixtures plugins, so neither CompilePlugin nor the Grails
    Gradle plugin reached its compileTestFixturesGroovy task and Spock's AST
    transform aborted it on Groovy 6. The root build now sets the opt-out on
    every module's GroovyCompile fork and Test JVM, guarded so a module that
    also gets it from CompilePlugin carries it once.
---
 .../org/apache/grails/buildsrc/CompilePlugin.groovy    |  7 +++++--
 build.gradle                                           | 18 ++++++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/CompilePlugin.groovy b/build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/CompilePlugin.groovy
index c61250d830..ffe20a923f 100644
--- a/build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/CompilePlugin.groovy
+++ b/build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/CompilePlugin.groovy
@@ -138,8 +138,11 @@ class CompilePlugin implements Plugin<Project> {
                 // version inside the forked compiler, failing with IncompatibleGroovyVersionException.
                 // Remove when the BOM moves to a Spock build for Groovy 6. App test build: an
                 // application's build gets the same flag from the Grails Gradle plugin.
-                it.groovyOptions.forkOptions.jvmArgs = (it.groovyOptions.forkOptions.jvmArgs ?: []) +
-                        ['-Dspock.iKnowWhatImDoing.disableGroovyVersionCheck=true']
+                List<String> groovyForkJvmArgs = it.groovyOptions.forkOptions.jvmArgs ?: []
+                if (!groovyForkJvmArgs.any { String arg -> arg.startsWith('-Dspock.iKnowWhatImDoing.disableGroovyVersionCheck=') }) {
+                    it.groovyOptions.forkOptions.jvmArgs = groovyForkJvmArgs +
+                            ['-Dspock.iKnowWhatImDoing.disableGroovyVersionCheck=true']
+                }
                 // Publish THIS project's base.dir to the forked Groovy compiler. Gradle reuses a forked
                 // compiler daemon for a task whose requested fork arguments the daemon already satisfies,
                 // so a compile that does NOT request base.dir can be handed a daemon started for another
diff --git a/build.gradle b/build.gradle
index 247df0213d..5cd6a4d203 100644
--- a/build.gradle
+++ b/build.gradle
@@ -154,6 +154,24 @@ subprojects {
             dependencies.add(sourceSet.compileOnlyConfigurationName, groovyCallsite)
             dependencies.add(sourceSet.runtimeOnlyConfigurationName, groovyCallsite)
         }
+
+        // Groovy 6 with Spock 2.4-groovy-5.0 (#16157): Spock's global AST transform checks the Groovy
+        // major inside the forked compiler, and Spock checks it again when a Spec starts. CompilePlugin
+        // and the Grails Gradle plugin set the opt-out for the modules that apply them; this covers the
+        // rest, such as test-example helpers that apply only the groovy plugin, without doubling it.
+        // Remove when the BOM moves to a Spock build for Groovy 6.
+        String spockOptOut = '-Dspock.iKnowWhatImDoing.disableGroovyVersionCheck=true'
+        tasks.withType(GroovyCompile).configureEach { GroovyCompile compile ->
+            List<String> forkJvmArgs = compile.groovyOptions.forkOptions.jvmArgs ?: []
+            if (!forkJvmArgs.any { String arg -> arg.startsWith('-Dspock.iKnowWhatImDoing.disableGroovyVersionCheck=') }) {
+                compile.groovyOptions.forkOptions.jvmArgs = forkJvmArgs + [spockOptOut]
+            }
+        }
+        tasks.withType(Test).configureEach { Test testTask ->
+            if (!testTask.systemProperties.containsKey('spock.iKnowWhatImDoing.disableGroovyVersionCheck')) {
+                testTask.systemProperty('spock.iKnowWhatImDoing.disableGroovyVersionCheck', 'true')
+            }
+        }
     }
 
     configurations.configureEach {