Skip to content

Commit 8dbb060

Browse files
committed
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
1 parent 69e47e3 commit 8dbb060

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

grails-forge/grails-forge-core/src/main/java/org/grails/forge/feature/build/gradle/templates/buildGradle.rocker.raw

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,3 @@ assets {
142142

143143
}
144144

145-
// https://github.com/apache/grails-core/issues/15321
146-
tasks.withType(GroovyCompile).configureEach {
147-
groovyOptions.optimizationOptions.indy = false
148-
}

grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ class GrailsExtension {
7676
*/
7777
boolean micronautAutoSetup = true
7878

79+
/**
80+
* Whether to enable Groovy's invokedynamic (indy) bytecode instruction for dynamic Groovy method dispatch.
81+
* Disabled by default to improve performance (see GitHub issue #15293).
82+
* When enabled, Groovy uses JVM invokedynamic instead of traditional callsite caching.
83+
* To enable invokedynamic in build.gradle: grails { indy = true }
84+
*/
85+
boolean indy = false
86+
7987
DependencyHandler getPlugins() {
8088
if (pluginDefiner == null) {
8189
pluginDefiner = new PluginDefiner(project)

grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,14 @@ class GrailsGradlePlugin extends GroovyPlugin {
184184
private void configureGroovyCompiler(Project project) {
185185
Provider<RegularFile> groovyCompilerConfigFile = project.layout.buildDirectory.file('grailsGroovyCompilerConfig.groovy')
186186

187+
GrailsExtension grailsExtension = project.extensions.findByType(GrailsExtension)
188+
187189
project.tasks.withType(GroovyCompile).configureEach { GroovyCompile c ->
188190
c.outputs.file(groovyCompilerConfigFile)
189191

192+
// Configure indy option from GrailsExtension
193+
c.groovyOptions.optimizationOptions.indy = grailsExtension?.indy ?: false
194+
190195
Closure<String> userScriptGenerator = getGroovyCompilerScript(c, project)
191196
c.doFirst {
192197
// 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 {
216221
c.groovyOptions.configurationScript = combinedFile
217222
}
218223
}
224+
225+
// Log indy status once per project after evaluation
226+
project.afterEvaluate {
227+
if (!grailsExtension?.indy) {
228+
project.logger.lifecycle("Grails: Groovy invokedynamic (indy) is disabled to improve performance (see issue #15293).")
229+
project.logger.lifecycle(" To enable invokedynamic: grails { indy = true } in build.gradle")
230+
}
231+
}
219232
}
220233

221234
protected Closure<String> getGroovyCompilerScript(GroovyCompile compile, Project project) {

grails-profiles/base/skeleton/build.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,3 @@ tasks.withType(Test).configureEach {
2727
useJUnitPlatform()
2828
}
2929

30-
// https://github.com/apache/grails-core/issues/15321
31-
tasks.withType(GroovyCompile).configureEach {
32-
groovyOptions.optimizationOptions.indy = false
33-
}

0 commit comments

Comments
 (0)