-
-
Notifications
You must be signed in to change notification settings - Fork 969
Preserving Parameter Names #15382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 8.0.x
Are you sure you want to change the base?
Preserving Parameter Names #15382
Changes from 6 commits
38e1ed7
127f01e
13675ab
7661d1c
1a83ae0
88586a0
8ec535d
aa0afee
f231d92
90b8a5a
fc9a55a
f888201
fa61946
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,7 @@ class GrailsExtension { | |
| this.project = project | ||
| this.pluginDefiner = new PluginDefiner(project) | ||
| this.indy = project.objects.property(Boolean).convention(false) | ||
| this.preserveParameterNames = project.objects.property(Boolean).convention(true) | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -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) { | ||
|
||
| this.preserveParameterNames.set(enabled) | ||
| } | ||
|
|
||
| DependencyHandler getPlugins() { | ||
| if (pluginDefiner == null) { | ||
| pluginDefiner = new PluginDefiner(project) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| package org.grails.gradle.plugin.core | ||
|
|
||
| class GrailsGradlePreserveParametersSpec extends GradleSpecification { | ||
|
|
||
| def "Grails extension is created with default preserveParameterNames = true"() { | ||
| given: | ||
| setupTestResourceProject('preserve-params-default') | ||
|
|
||
| when: | ||
| def result = executeTask('inspectPreserveParam') | ||
|
|
||
| then: | ||
| result.output.contains("HAS_PRESERVE_PARAM_ENABLED=true") | ||
| } | ||
|
|
||
| def "preserveParameterNames can be configured to false via grails block"() { | ||
| given: | ||
| setupTestResourceProject('preserve-params-disabled') | ||
|
|
||
| when: | ||
| def result = executeTask('inspectPreserveParam') | ||
|
|
||
| then: | ||
| result.output.contains("HAS_PRESERVE_PARAM_ENABLED=false") | ||
| } | ||
|
|
||
| def "GroovyCompile tasks get parameters = true when preserveParameterNames is enabled"() { | ||
| given: | ||
| setupTestResourceProject('preserve-params-enabled') | ||
|
|
||
| when: | ||
| def result = executeTask('inspectPreserveParam') | ||
|
|
||
| then: | ||
| result.output.contains("HAS_PRESERVE_PARAM_ENABLED=true") | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| plugins { | ||
| id 'org.apache.grails.gradle.grails-app' | ||
| } | ||
|
|
||
| tasks.register('inspectPreserveParam') { | ||
| doLast { | ||
| def compileTasks = tasks.withType(GroovyCompile) | ||
| def paramsEnabled = compileTasks.every { it.groovyOptions.parameters } | ||
| println "HAS_PRESERVE_PARAM_ENABLED=${paramsEnabled}" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| grailsVersion=__PROJECT_VERSION__ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| rootProject.name = 'test-preserve-params-default' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| plugins { | ||
| id 'org.apache.grails.gradle.grails-app' | ||
| } | ||
|
|
||
| grails { | ||
| preserveParameterNames = false | ||
| } | ||
|
|
||
| tasks.register('inspectPreserveParam') { | ||
| doLast { | ||
| def compileTasks = tasks.withType(GroovyCompile) | ||
| def paramsEnabled = compileTasks.every { it.groovyOptions.parameters } | ||
| println "HAS_PRESERVE_PARAM_ENABLED=${paramsEnabled}" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| grailsVersion=__PROJECT_VERSION__ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| rootProject.name = 'test-preserve-params-disabled' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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}" | ||
jdaugherty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| grailsVersion=__PROJECT_VERSION__ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| rootProject.name = 'test-preserve-params-enabled' |
Uh oh!
There was an error while loading. Please reload this page.