jamesfredley commented on code in PR #15375: URL: https://github.com/apache/grails-core/pull/15375#discussion_r2828018935
########## grails-doc/src/en/guide/upgrading/upgrading60x.adoc: ########## @@ -61,16 +61,27 @@ In your gradle file, you can force a dependency upgrade via this code: } ---- -* By default, Groovy 4 switches away from callsite optimizations and uses invokedynamic instead. This can result in performance regressions compared to Grails 6. Groovy 5 will remove the ability to disable invokedynamic, but to disable it for Groovy 4, modify your `build.gradle` to include the following: +* By default, Groovy 4 switches away from callsite optimizations and uses invokedynamic instead. This can result in performance regressions compared to Grails 6. The Grails Gradle Plugin now automatically disables invokedynamic for all `GroovyCompile` tasks (see https://github.com/apache/grails-core/issues/15293[#15293]). If you have a manual `tasks.withType(GroovyCompile)` block in your `build.gradle` that sets `indy = false`, you can safely remove it: [source,groovy] -.build.gradle +.build.gradle - remove this block (no longer needed) ---- + // This is now handled by the Grails Gradle Plugin - remove it tasks.withType(GroovyCompile).configureEach { groovyOptions.optimizationOptions.indy = false } ---- +To re-enable invokedynamic, use the `grails` extension in your `build.gradle`: + +[source,groovy] +.build.gradle +---- + grails { + indy = true Review Comment: Fixed - added `setIndy(boolean)` setter to `GrailsExtension` so the `grails { indy = true }` DSL syntax works correctly with the `Property<Boolean>` field. ########## 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?.getOrElse(false) ?: false + Review Comment: Fixed - moved the indy configuration into `afterEvaluate` so it reads the final extension value after the user's `grails { }` block has been evaluated. ########## grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy: ########## @@ -76,6 +78,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 } + */ + final Property<Boolean> indy + Review Comment: Fixed - added the `setIndy(boolean)` setter as suggested, delegating to `indy.set(...)`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
