From da35cade5e9f5c78a636e756b146abc0a9390628 Mon Sep 17 00:00:00 2001 From: Puneet Behl Date: Thu, 14 May 2020 13:49:55 +0530 Subject: [PATCH 1/4] Force Groovy version 3.0.3 --- .../plugin/core/GrailsGradlePlugin.groovy | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy b/grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy index e5cd08c326c..fb095999e87 100644 --- a/grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy +++ b/grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy @@ -31,7 +31,10 @@ import org.gradle.api.Action import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task -import org.gradle.api.artifacts.* +import org.gradle.api.artifacts.Configuration +import org.gradle.api.artifacts.ConfigurationContainer +import org.gradle.api.artifacts.Dependency +import org.gradle.api.artifacts.DependencyResolveDetails import org.gradle.api.file.FileCollection import org.gradle.api.java.archives.Manifest import org.gradle.api.plugins.ExtraPropertiesExtension @@ -43,6 +46,7 @@ import org.gradle.api.tasks.testing.Test import org.gradle.language.jvm.tasks.ProcessResources import org.gradle.process.JavaForkOptions import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry +import org.gradle.util.VersionNumber import org.grails.build.parsing.CommandLineParser import org.grails.gradle.plugin.agent.AgentTasksEnhancer import org.grails.gradle.plugin.commands.ApplicationContextCommandTask @@ -94,6 +98,8 @@ class GrailsGradlePlugin extends GroovyPlugin { applyDefaultPlugins(project) + configureGroovy(project) + registerToolingModelBuilder(project, registry) registerGrailsExtension(project) @@ -208,6 +214,23 @@ class GrailsGradlePlugin extends GroovyPlugin { } } + @CompileStatic + protected void configureGroovy(Project project) { + project.configurations.all( { Configuration configuration -> + configuration.resolutionStrategy.eachDependency({ DependencyResolveDetails details -> + String dependencyName = details.requested.name + String group = details.requested.group + String version = details.requested.version + final String minimumSupportedGroovyVersion = '3.0.3' + final String groovyVersion = VersionNumber.parse(version) >= VersionNumber.parse(minimumSupportedGroovyVersion) ? version : minimumSupportedGroovyVersion + if (group == 'org.codehaus.groovy' && dependencyName.startsWith('groovy')) { + details.useVersion(groovyVersion) + return + } + } as Action) + } as Action) + } + @CompileStatic protected void configureSpringBootExtension(Project project) { def springBoot = project.extensions.findByType(SpringBootExtension) From 661367117aff51fc8bc05ea6dd248b09014d9e8b Mon Sep 17 00:00:00 2001 From: Puneet Behl Date: Thu, 14 May 2020 14:09:20 +0530 Subject: [PATCH 2/4] Update force groovy version logic * Remove version comparison * Read groovyVersion from project properties --- .../org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy b/grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy index fb095999e87..f597bd40f39 100644 --- a/grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy +++ b/grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy @@ -46,7 +46,6 @@ import org.gradle.api.tasks.testing.Test import org.gradle.language.jvm.tasks.ProcessResources import org.gradle.process.JavaForkOptions import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry -import org.gradle.util.VersionNumber import org.grails.build.parsing.CommandLineParser import org.grails.gradle.plugin.agent.AgentTasksEnhancer import org.grails.gradle.plugin.commands.ApplicationContextCommandTask @@ -221,8 +220,7 @@ class GrailsGradlePlugin extends GroovyPlugin { String dependencyName = details.requested.name String group = details.requested.group String version = details.requested.version - final String minimumSupportedGroovyVersion = '3.0.3' - final String groovyVersion = VersionNumber.parse(version) >= VersionNumber.parse(minimumSupportedGroovyVersion) ? version : minimumSupportedGroovyVersion + final String groovyVersion = project.properties['groovyVersion'] ?: '3.0.3' if (group == 'org.codehaus.groovy' && dependencyName.startsWith('groovy')) { details.useVersion(groovyVersion) return From d7810f3233daf08ebf2af4185cee8bbbfd0dc315 Mon Sep 17 00:00:00 2001 From: Puneet Behl Date: Fri, 15 May 2020 00:23:30 +0530 Subject: [PATCH 3/4] Only force if groovyVersion property is present --- .../grails/gradle/plugin/core/GrailsGradlePlugin.groovy | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy b/grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy index f597bd40f39..d96e16cbda6 100644 --- a/grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy +++ b/grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy @@ -215,18 +215,19 @@ class GrailsGradlePlugin extends GroovyPlugin { @CompileStatic protected void configureGroovy(Project project) { - project.configurations.all( { Configuration configuration -> + final String groovyVersion = project.properties['groovyVersion'] + if (groovyVersion) { + project.configurations.all({ Configuration configuration -> configuration.resolutionStrategy.eachDependency({ DependencyResolveDetails details -> String dependencyName = details.requested.name String group = details.requested.group - String version = details.requested.version - final String groovyVersion = project.properties['groovyVersion'] ?: '3.0.3' if (group == 'org.codehaus.groovy' && dependencyName.startsWith('groovy')) { details.useVersion(groovyVersion) return } } as Action) - } as Action) + } as Action) + } } @CompileStatic From 7eaba1fbf40e09118c8c5d78e93cbc866c0f8928 Mon Sep 17 00:00:00 2001 From: Puneet Behl Date: Fri, 15 May 2020 00:52:06 +0530 Subject: [PATCH 4/4] Support groovyVersion in the profile skeleton --- .../org/grails/cli/profile/commands/CreateAppCommand.groovy | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grails-shell/src/main/groovy/org/grails/cli/profile/commands/CreateAppCommand.groovy b/grails-shell/src/main/groovy/org/grails/cli/profile/commands/CreateAppCommand.groovy index 3dccc028ccf..2f43d79a2e6 100644 --- a/grails-shell/src/main/groovy/org/grails/cli/profile/commands/CreateAppCommand.groovy +++ b/grails-shell/src/main/groovy/org/grails/cli/profile/commands/CreateAppCommand.groovy @@ -226,6 +226,10 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos if(gormDep != null) { variables['gorm.version'] = gormDep } + String groovyDep = mpr.profileDependencyVersions.versionProperties.get('groovy.version') + if(groovyDep != null) { + variables['groovy.version'] = groovyDep + } } Path appFullDirectory = Paths.get(cmd.baseDir.path, appname)