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

jamesfredley pushed a commit to branch feat/move-indy-config-to-gradle-plugin
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 8dbb060d62cfea6a823b8c9f8c37337faa90203b
Author: James Fredley <[email protected]>
AuthorDate: Tue Feb 3 12:27:11 2026 -0500

    feat(grails-gradle): move indy configuration from generated apps to Gradle 
plugin
    
    Move the Groovy invokedynamic (indy) configuration from generated
    build.gradle files to the Grails Gradle Plugin, centralizing the
    setting and providing user feedback.
    
    Changes:
    - Add 'indy' property to GrailsExtension (default: false)
    - Configure GroovyCompile tasks in GrailsGradlePlugin to use the
      extension's indy setting
    - Display lifecycle message explaining indy is disabled for
      performance and how to enable it
    - Remove hardcoded indy=false from grails-forge template
    - Remove hardcoded indy=false from grails-profiles base skeleton
    
    The message appears once per project during configuration:
      Grails: Groovy invokedynamic (indy) is disabled to improve
              performance (see issue #15293).
              To enable invokedynamic: grails { indy = true } in build.gradle
    
    Closes #15321
---
 .../feature/build/gradle/templates/buildGradle.rocker.raw   |  4 ----
 .../org/grails/gradle/plugin/core/GrailsExtension.groovy    |  8 ++++++++
 .../org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy | 13 +++++++++++++
 grails-profiles/base/skeleton/build.gradle                  |  4 ----
 4 files changed, 21 insertions(+), 8 deletions(-)

diff --git 
a/grails-forge/grails-forge-core/src/main/java/org/grails/forge/feature/build/gradle/templates/buildGradle.rocker.raw
 
b/grails-forge/grails-forge-core/src/main/java/org/grails/forge/feature/build/gradle/templates/buildGradle.rocker.raw
index a1b84c1858..dac75d577b 100644
--- 
a/grails-forge/grails-forge-core/src/main/java/org/grails/forge/feature/build/gradle/templates/buildGradle.rocker.raw
+++ 
b/grails-forge/grails-forge-core/src/main/java/org/grails/forge/feature/build/gradle/templates/buildGradle.rocker.raw
@@ -142,7 +142,3 @@ assets {
 
 }
 
-// https://github.com/apache/grails-core/issues/15321
-tasks.withType(GroovyCompile).configureEach {
-    groovyOptions.optimizationOptions.indy = false
-}
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 75a6c80297..107c0a7c5d 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
@@ -76,6 +76,14 @@ class GrailsExtension {
      */
     boolean micronautAutoSetup = true
 
+    /**
+     * Whether to enable Groovy's invokedynamic (indy) bytecode instruction 
for dynamic Groovy method dispatch.
+     * Disabled by default to improve performance (see GitHub issue #15293).
+     * When enabled, Groovy uses JVM invokedynamic instead of traditional 
callsite caching.
+     * To enable invokedynamic in build.gradle: grails { indy = true }
+     */
+    boolean indy = false
+
     DependencyHandler getPlugins() {
         if (pluginDefiner == null) {
             pluginDefiner = new PluginDefiner(project)
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 123a2b76d3..a0b3286e89 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
@@ -184,9 +184,14 @@ class GrailsGradlePlugin extends GroovyPlugin {
     private void configureGroovyCompiler(Project project) {
         Provider<RegularFile> groovyCompilerConfigFile = 
project.layout.buildDirectory.file('grailsGroovyCompilerConfig.groovy')
 
+        GrailsExtension grailsExtension = 
project.extensions.findByType(GrailsExtension)
+
         project.tasks.withType(GroovyCompile).configureEach { GroovyCompile c 
->
             c.outputs.file(groovyCompilerConfigFile)
 
+            // Configure indy option from GrailsExtension
+            c.groovyOptions.optimizationOptions.indy = grailsExtension?.indy 
?: false
+
             Closure<String> userScriptGenerator = getGroovyCompilerScript(c, 
project)
             c.doFirst {
                 // This isn't ideal - we're performing configuration at 
execution time, but the alternative would be having
@@ -216,6 +221,14 @@ class GrailsGradlePlugin extends GroovyPlugin {
                 c.groovyOptions.configurationScript = combinedFile
             }
         }
+
+        // Log indy status once per project after evaluation
+        project.afterEvaluate {
+            if (!grailsExtension?.indy) {
+                project.logger.lifecycle("Grails: Groovy invokedynamic (indy) 
is disabled to improve performance (see issue #15293).")
+                project.logger.lifecycle("        To enable invokedynamic: 
grails { indy = true } in build.gradle")
+            }
+        }
     }
 
     protected Closure<String> getGroovyCompilerScript(GroovyCompile compile, 
Project project) {
diff --git a/grails-profiles/base/skeleton/build.gradle 
b/grails-profiles/base/skeleton/build.gradle
index 99627b224f..cb32eb4613 100644
--- a/grails-profiles/base/skeleton/build.gradle
+++ b/grails-profiles/base/skeleton/build.gradle
@@ -27,7 +27,3 @@ tasks.withType(Test).configureEach {
     useJUnitPlatform()
 }
 
-// https://github.com/apache/grails-core/issues/15321
-tasks.withType(GroovyCompile).configureEach {
-    groovyOptions.optimizationOptions.indy = false
-}

Reply via email to