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..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 @@ -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 @@ -94,6 +97,8 @@ class GrailsGradlePlugin extends GroovyPlugin { applyDefaultPlugins(project) + configureGroovy(project) + registerToolingModelBuilder(project, registry) registerGrailsExtension(project) @@ -208,6 +213,23 @@ class GrailsGradlePlugin extends GroovyPlugin { } } + @CompileStatic + protected void configureGroovy(Project project) { + 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 + 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) 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 b3b90c28396..10485513fa8 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 @@ -227,6 +227,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)