jdaugherty commented on code in PR #15382:
URL: https://github.com/apache/grails-core/pull/15382#discussion_r2868314153
##########
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy:
##########
@@ -229,14 +229,18 @@ class GrailsGradlePlugin implements Plugin<Project> {
// Configure indy and log status after evaluation so user's grails { }
block has been applied
project.afterEvaluate {
boolean indyEnabled = grailsExtension?.indy?.getOrElse(false) ?:
false
+ boolean preserveParameterNames =
grailsExtension?.preserveParameterNames != null
+ ? grailsExtension.preserveParameterNames.getOrElse(true) : true
project.tasks.withType(GroovyCompile).configureEach {
GroovyCompile c ->
c.groovyOptions.optimizationOptions.indy = indyEnabled
+ c.groovyOptions.parameters = preserveParameterNames
Review Comment:
if null this should not be set
##########
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy:
##########
@@ -229,14 +229,18 @@ class GrailsGradlePlugin implements Plugin<Project> {
// Configure indy and log status after evaluation so user's grails { }
block has been applied
project.afterEvaluate {
boolean indyEnabled = grailsExtension?.indy?.getOrElse(false) ?:
false
+ boolean preserveParameterNames =
grailsExtension?.preserveParameterNames != null
+ ? grailsExtension.preserveParameterNames.getOrElse(true) : true
project.tasks.withType(GroovyCompile).configureEach {
GroovyCompile c ->
c.groovyOptions.optimizationOptions.indy = indyEnabled
+ c.groovyOptions.parameters = preserveParameterNames
}
if (!indyEnabled) {
project.logger.info('Grails: Groovy invokedynamic (indy) is
disabled to improve performance (see issue #15293).')
project.logger.info(' To enable invokedynamic: grails {
indy = true } in build.gradle')
}
- }
+ project.logger.info("Grails: Parameter name preservation is
${preserveParameterNames ? 'enabled' : 'disabled'} (-parameters flag). " +
Review Comment:
we can remove the log comment
##########
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy:
##########
@@ -229,14 +229,18 @@ class GrailsGradlePlugin implements Plugin<Project> {
// Configure indy and log status after evaluation so user's grails { }
block has been applied
project.afterEvaluate {
boolean indyEnabled = grailsExtension?.indy?.getOrElse(false) ?:
false
+ boolean preserveParameterNames =
grailsExtension?.preserveParameterNames != null
+ ? grailsExtension.preserveParameterNames.getOrElse(true) : true
Review Comment:
this should be a simple true/false/null
##########
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy:
##########
@@ -106,6 +107,18 @@ class GrailsExtension {
this.indy.set(enabled)
}
+ /**
+ * Preserve method parameter names in .class files (enables better IDE
code completion for method parameters,
+ * reflection-based tools, bean introspection, etc.).
+ * Corresponds to groovyc `-parameters`.
+ * Default: true (See #13028)
+ */
+ final Property<Boolean> preserveParameterNames
+
+ void setPreserveParameterNames(boolean enabled) {
Review Comment:
This is unnecessary
##########
grails-gradle/plugins/src/test/resources/test-projects/preserve-params-enabled/build.gradle:
##########
@@ -0,0 +1,15 @@
+plugins {
+ id 'org.apache.grails.gradle.grails-app'
+}
+
+grails {
+ preserveParameterNames = true
+}
+
+tasks.register('inspectPreserveParam') {
+ doLast {
+ def compileTasks = tasks.withType(GroovyCompile)
+ def paramsEnabled = compileTasks.every { it.groovyOptions.parameters }
+ println "HAS_PRESERVE_PARAM_ENABLED=${paramsEnabled}"
Review Comment:
thank you for adding tests as you make these changes
##########
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy:
##########
@@ -229,14 +229,18 @@ class GrailsGradlePlugin implements Plugin<Project> {
// Configure indy and log status after evaluation so user's grails { }
block has been applied
project.afterEvaluate {
boolean indyEnabled = grailsExtension?.indy?.getOrElse(false) ?:
false
Review Comment:
grails extension must never be null at this point; we can remove the null
safety
##########
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy:
##########
@@ -106,6 +107,18 @@ class GrailsExtension {
this.indy.set(enabled)
}
+ /**
+ * Preserve method parameter names in .class files (enables better IDE
code completion for method parameters,
Review Comment:
The main reason we are doing this is so grails do not have to specify
'@Qualifier' for wiring by name. The idea completion is a bonus
--
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]