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

jdaugherty pushed a commit to branch feat/indy-default-groovy6
in repository https://gitbox.apache.org/repos/asf/grails-core.git


The following commit(s) were added to refs/heads/feat/indy-default-groovy6 by 
this push:
     new 17d694d3af Ship groovy-callsite only when an application opts out of 
invokedynamic
17d694d3af is described below

commit 17d694d3af25c224bfc4c13855761d8c343a1a64
Author: James Daugherty <[email protected]>
AuthorDate: Thu Oct 15 01:50:59 2026 +0100

    Ship groovy-callsite only when an application opts out of invokedynamic
    
    grails-common declared org.apache.groovy:groovy-callsite as an api
    dependency, so every Grails 9 application carried the module whether or
    not it compiled classic call sites, which Grails 9 does not by default.
    The dependency is gone: an application that sets grails { indy = false }
    declares the module itself, at the version the Grails BOM manages, and
    the Groovy compiler names it when it is missing. What's New, the 9.0
    upgrade guide and the extension's javadoc say so.
    
    CI's -PgrailsIndy=false lane compiles every source set of the Grails
    plugin modules and example apps with classic call sites, so the shared
    grails-extension-gradle-config script, which applies that flag, now
    declares the module for each source set of such a project. The version
    is read from the map in dependencies.gradle, applied to the root project
    once in that lane as the build-logic builds apply it, because the ast
    source set the Grails plugin gives every plugin project has no platform
    on its configurations to supply one.
    The Forge CLI test fixtures no longer need their own declaration: they
    compile with invokedynamic like everything else.
    
    The TestKit fixtures' Groovy sources that the previous commit's bytecode
    and late-override features compile were left out of it; they are added.
---
 .../org/apache/grails/buildsrc/CompilePlugin.groovy   |  4 ++--
 gradle/grails-extension-gradle-config.gradle          | 19 ++++++++++++++++++-
 grails-common/build.gradle                            |  5 -----
 grails-doc/src/en/guide/introduction/whatsNew.adoc    | 12 +++++++++++-
 grails-doc/src/en/guide/upgrading/upgrading90x.adoc   |  2 +-
 grails-forge/grails-forge-cli/build.gradle            |  4 ----
 .../grails/gradle/plugin/core/GrailsExtension.groovy  |  4 ++--
 .../gradle/plugin/core/GrailsGradlePlugin.groovy      |  2 +-
 .../indy-settings/src/main/groovy/demo/Dynamic.groovy |  5 +++++
 .../src/main/groovy/demo/Dynamic.groovy               |  5 +++++
 10 files changed, 45 insertions(+), 17 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 a605174a20..c6bf408d62 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
@@ -121,8 +121,8 @@ class CompilePlugin implements Plugin<Project> {
                 // bytecode into the optional groovy-callsite module 
(GROOVY-11158), which the
                 // framework's library modules do not carry, so they never opt 
out. -PgrailsIndy
                 // (see grails-extension-gradle-config.gradle) still governs 
the Grails plugin
-                // modules, which get groovy-callsite through grails-common, 
and applications
-                // opt out with grails { indy = false }.
+                // modules, which that script gives groovy-callsite when the 
lane turns indy off,
+                // and applications opt out with grails { indy = false } plus 
that dependency.
                 it.groovyOptions.optimizationOptions.put('indy', true)
                 // encoding needs to be the same since it's different across 
platforms
                 it.options.encoding = StandardCharsets.UTF_8.name()
diff --git a/gradle/grails-extension-gradle-config.gradle 
b/gradle/grails-extension-gradle-config.gradle
index cfcf12cd92..79db55b532 100644
--- a/gradle/grails-extension-gradle-config.gradle
+++ b/gradle/grails-extension-gradle-config.gradle
@@ -39,4 +39,21 @@ grails {
     if (project.hasProperty('grailsIndy')) {
         indy = project.property('grailsIndy').toString().trim().toBoolean()
     }
-}
\ No newline at end of file
+}
+
+// GROOVY-11158: Groovy 6 generates classic (non-invokedynamic) call sites 
only with the optional
+// groovy-callsite module on the classpath. Grails does not carry it: an 
application that opts out with
+// grails { indy = false } declares it itself, so an application that keeps 
the default never ships it.
+// The -PgrailsIndy=false CI lane compiles every source set of this project 
that way, so it declares the
+// module here for each of them. The version is named outright, read from the 
map in dependencies.gradle
+// that the BOM projects publish, because the ast source set the Grails plugin 
gives a plugin project has
+// no platform on its configurations to supply one.
+if (project.hasProperty('grailsIndy') && 
!project.property('grailsIndy').toString().trim().toBoolean()) {
+    if (!rootProject.ext.has('bomDependencyVersions')) {
+        rootProject.apply from: 
rootProject.layout.projectDirectory.file('dependencies.gradle')
+    }
+    String callSiteModule = 
"org.apache.groovy:groovy-callsite:${rootProject.ext.bomDependencyVersions['groovy.version']}"
+    sourceSets.configureEach { SourceSet sourceSet ->
+        dependencies.add(sourceSet.implementationConfigurationName, 
callSiteModule)
+    }
+}
diff --git a/grails-common/build.gradle b/grails-common/build.gradle
index 71db645ff2..2b8ee5f649 100644
--- a/grails-common/build.gradle
+++ b/grails-common/build.gradle
@@ -42,11 +42,6 @@ dependencies {
 
     api 'org.apache.grails.gradle:grails-gradle-common'
     api 'org.apache.groovy:groovy'
-    // GROOVY-11158: Groovy 6 moved classic (non-invokedynamic) call-site 
bytecode generation into the
-    // optional groovy-callsite module. Grails 9 compiles with invokedynamic, 
the compiler's default, but an
-    // application may opt out with grails { indy = false }, and CI's 
-PgrailsIndy=false lane does; both
-    // need the module on the compile and runtime classpath, which every 
Grails application gets from here.
-    api 'org.apache.groovy:groovy-callsite'
     api 'org.slf4j:jcl-over-slf4j'
     api 'org.slf4j:slf4j-api'
     api 'org.springframework:spring-context', {
diff --git a/grails-doc/src/en/guide/introduction/whatsNew.adoc 
b/grails-doc/src/en/guide/introduction/whatsNew.adoc
index 22e8474aea..2af131eb34 100644
--- a/grails-doc/src/en/guide/introduction/whatsNew.adoc
+++ b/grails-doc/src/en/guide/introduction/whatsNew.adoc
@@ -58,7 +58,17 @@ grails {
 }
 ----
 
-On Groovy 6, classic call sites need `org.apache.groovy:groovy-callsite` on 
the classpath. A Grails application already receives it through its Grails 
dependencies, at the version the Grails BOM manages.
+On Groovy 6, classic call sites need `org.apache.groovy:groovy-callsite` on 
the classpath. Grails does not carry it, so an application that opts out 
declares it, at the version the Grails BOM manages:
+
+[source,groovy]
+.build.gradle
+----
+dependencies {
+    implementation 'org.apache.groovy:groovy-callsite'
+}
+----
+
+An application that keeps the default never ships the module.
 
 ==== Spring Boot 4.1 and Spring Framework 7
 
diff --git a/grails-doc/src/en/guide/upgrading/upgrading90x.adoc 
b/grails-doc/src/en/guide/upgrading/upgrading90x.adoc
index 26bf9ff581..115689c13e 100644
--- a/grails-doc/src/en/guide/upgrading/upgrading90x.adoc
+++ b/grails-doc/src/en/guide/upgrading/upgrading90x.adoc
@@ -63,5 +63,5 @@ grails {
 }
 ----
 
-Classic call sites on Groovy 6 need `org.apache.groovy:groovy-callsite` on the 
classpath, which a Grails application receives through its Grails dependencies. 
A source set that does not see the application's dependencies, such as the test 
fixtures of Gradle's `java-test-fixtures` plugin, needs that dependency 
declared for it as well when `indy` is `false`.
+Classic call sites on Groovy 6 need `org.apache.groovy:groovy-callsite` on the 
classpath. Grails does not carry it, so an application that sets `indy` to 
`false` declares `implementation 'org.apache.groovy:groovy-callsite'` itself, 
at the version the Grails BOM manages, and again for every source set that does 
not see its implementation dependencies, such as the test fixtures of Gradle's 
`java-test-fixtures` plugin. Without it the Groovy compiler stops with a 
message naming the module.
 
diff --git a/grails-forge/grails-forge-cli/build.gradle 
b/grails-forge/grails-forge-cli/build.gradle
index 121b4e3954..7e324417c1 100644
--- a/grails-forge/grails-forge-cli/build.gradle
+++ b/grails-forge/grails-forge-cli/build.gradle
@@ -110,10 +110,6 @@ dependencies {
     // CliRunner, the fixture the specs run one command bean with
     testFixturesImplementation 
platform("org.apache.grails:grails-bom:$projectVersion")
     testFixturesImplementation 'org.apache.groovy:groovy'
-    // GROOVY-11158: CI's -PgrailsIndy=false lane compiles every Groovy source 
set without invokedynamic,
-    // which Groovy 6 supports only with groovy-callsite on the classpath. The 
application's own source sets
-    // get it through grails-common; the fixtures see none of the 
application's implementation dependencies.
-    testFixturesImplementation 'org.apache.groovy:groovy-callsite'
     testFixturesImplementation 'org.springframework:spring-context'
     testFixturesImplementation "info.picocli:picocli:$picocliVersion"
 
diff --git 
a/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy
 
b/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy
index 2927b60dc9..c468d23c6c 100644
--- 
a/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy
+++ 
b/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy
@@ -245,8 +245,8 @@ class GrailsExtension {
      * Whether Groovy compiles dynamic calls with the JVM's invokedynamic 
instruction (indy) or with classic
      * call sites. Unset by default: the Grails plugin then leaves every 
Groovy compile task at the Groovy
      * compiler's own default, which is invokedynamic. Set it to {@code false} 
to compile classic call sites;
-     * on Groovy 6 those need {@code org.apache.groovy:groovy-callsite} on the 
classpath, which a Grails
-     * application receives through its Grails dependencies. A value set here 
is applied to every
+     * on Groovy 6 those need {@code org.apache.groovy:groovy-callsite} on the 
classpath, which the
+     * application declares itself, at the version the Grails BOM manages. A 
value set here is applied to every
      * {@code GroovyCompile} task after the build script has run.
      */
     final Property<Boolean> indy
diff --git 
a/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
 
b/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
index 59c97f95a2..ea19e72c95 100644
--- 
a/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
+++ 
b/grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy
@@ -298,7 +298,7 @@ class GrailsGradlePlugin implements Plugin<Project> {
                 project.logger.info('Grails: Groovy invokedynamic (indy) is 
enabled.')
             } else {
                 project.logger.info('Grails: Groovy invokedynamic (indy) is 
disabled.')
-                project.logger.info('        Non-indy Groovy 6 builds need 
org.apache.groovy:groovy-callsite on the classpath.')
+                project.logger.info('        Non-indy Groovy 6 builds need 
org.apache.groovy:groovy-callsite on the classpath: declare it as a 
dependency.')
             }
         }
     }
diff --git 
a/grails-gradle/plugins/src/test/resources/test-projects/indy-settings/src/main/groovy/demo/Dynamic.groovy
 
b/grails-gradle/plugins/src/test/resources/test-projects/indy-settings/src/main/groovy/demo/Dynamic.groovy
new file mode 100644
index 0000000000..fa38802008
--- /dev/null
+++ 
b/grails-gradle/plugins/src/test/resources/test-projects/indy-settings/src/main/groovy/demo/Dynamic.groovy
@@ -0,0 +1,5 @@
+package demo
+
+class Dynamic {
+    def run(x) { x.toString().size() + x.hashCode() }
+}
diff --git 
a/grails-gradle/plugins/src/test/resources/test-projects/native-defaults-on/src/main/groovy/demo/Dynamic.groovy
 
b/grails-gradle/plugins/src/test/resources/test-projects/native-defaults-on/src/main/groovy/demo/Dynamic.groovy
new file mode 100644
index 0000000000..fa38802008
--- /dev/null
+++ 
b/grails-gradle/plugins/src/test/resources/test-projects/native-defaults-on/src/main/groovy/demo/Dynamic.groovy
@@ -0,0 +1,5 @@
+package demo
+
+class Dynamic {
+    def run(x) { x.toString().size() + x.hashCode() }
+}

Reply via email to