Skip to content

Commit 6b8444b

Browse files
graemerocherjeffscottbrown
authored andcommitted
introduce new configuration option that disables parsing of dependencies.groovy completely so that only POM data is used. Parsing dependencies.groovy is disabled by default for new applications.
Conflicts: grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/AbstractIvyDependencyManager.java
1 parent 5a55105 commit 6b8444b

File tree

6 files changed

+32
-8
lines changed

6 files changed

+32
-8
lines changed

grails-bootstrap/src/main/groovy/grails/util/BuildSettings.groovy

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,11 +1293,14 @@ class BuildSettings extends AbstractBuildSettings {
12931293
try {
12941294
Script script = gcl.parseClass(pluginDependencyDescriptor)?.newInstance()
12951295
def pluginConfig = pluginSlurper.parse(script)
1296-
def pluginDependencyConfig = pluginConfig.grails.project.dependency.resolution
1297-
if (pluginDependencyConfig instanceof Closure) {
1298-
def excludeRules = pdd ? pdd.getExcludeRules(dependencyManager.configurationNames) : [] as ExcludeRule[]
12991296

1300-
dependencyManager.parseDependencies(pluginName, pluginDependencyConfig, excludeRules)
1297+
if(dependencyManager.isLegacyResolve()) {
1298+
def pluginDependencyConfig = pluginConfig.grails.project.dependency.resolution
1299+
if (pluginDependencyConfig instanceof Closure) {
1300+
def excludeRules = pdd ? pdd.getExcludeRules(dependencyManager.configurationNames) : [] as ExcludeRule[]
1301+
1302+
dependencyManager.parseDependencies(pluginName, pluginDependencyConfig, excludeRules)
1303+
}
13011304
}
13021305

13031306
def inlinePlugins = getInlinePluginsFromConfiguration(pluginConfig, dir)

grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/AbstractIvyDependencyManager.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,10 @@ public abstract class AbstractIvyDependencyManager {
142142
protected boolean hasApplicationDependencies = false;
143143
protected boolean readPom = false;
144144

145-
final protected IvySettings ivySettings;
146-
final protected BuildSettings buildSettings;
147-
final protected Metadata metadata;
145+
protected final IvySettings ivySettings;
146+
protected final BuildSettings buildSettings;
147+
protected final Metadata metadata;
148+
protected boolean legacyResolve = true;
148149
private boolean offline;
149150

150151
private ChainResolver chainResolver;
@@ -169,6 +170,18 @@ public AbstractIvyDependencyManager(IvySettings ivySettings, BuildSettings build
169170
updateChangingPattern();
170171
}
171172

173+
/**
174+
* Whether the legacy approach of parsing dependencies.groovy in addition to pom.xml should be used during dependency resolution
175+
*
176+
* @return True if it should
177+
*/
178+
public boolean isLegacyResolve() {
179+
return legacyResolve;
180+
}
181+
182+
public void setLegacyResolve(boolean legacyResolve) {
183+
this.legacyResolve = legacyResolve;
184+
}
172185

173186
public ResolveEngine getResolveEngine() {
174187
return resolveEngine;

grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/PluginInstallEngine.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,13 @@ You cannot upgrade a plugin that is configured via BuildConfig.groovy, remove th
464464
}
465465

466466
protected void resolvePluginJarDependencies(fullPluginName, pluginName, pluginInstallPath, Map runtimeDependencies = [:]) {
467+
IvyDependencyManager dependencyManager = settings.dependencyManager
468+
if(!dependencyManager.isLegacyResolve()) return;
467469
def pluginDependencyDescriptor = new File("$pluginInstallPath/dependencies.groovy")
468470
if (pluginDependencyDescriptor.exists() && !settings.isDependenciesExternallyConfigured()) {
469471
eventHandler "StatusUpdate", "Resolving plugin JAR dependencies"
470472
def callable = settings.pluginDependencyHandler()
471473
callable.call(new File("$pluginInstallPath"))
472-
IvyDependencyManager dependencyManager = settings.dependencyManager
473474
dependencyManager.resetGrailsPluginsResolver()
474475

475476
def dependencyConfigurationsToAdd = [IvyDependencyManager.RUNTIME_CONFIGURATION, IvyDependencyManager.BUILD_CONFIGURATION, IvyDependencyManager.PROVIDED_CONFIGURATION]

grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/config/DependencyConfigurationConfigurer.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class DependencyConfigurationConfigurer extends AbstractDependencyManagementConf
3131

3232
boolean pluginMode = false
3333
boolean repositoryMode = false
34+
boolean legacyResolve = true
3435

3536
DependencyConfigurationConfigurer(DependencyConfigurationContext context) {
3637
super(context)
@@ -40,6 +41,10 @@ class DependencyConfigurationConfigurer extends AbstractDependencyManagementConf
4041
dependencyManager.ivySettings.setVariable("ivy.checksums", checksumConfig)
4142
}
4243

44+
void legacyResolve(boolean lr) {
45+
dependencyManager.setLegacyResolve(lr)
46+
}
47+
4348
void checksums(boolean enable) {
4449
if (!enable) {
4550
dependencyManager.ivySettings.setVariable("ivy.checksums", "")

grails-resources/src/grails/grails-app/conf/BuildConfig.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ grails.project.dependency.resolution = {
1414
}
1515
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
1616
checksums true // Whether to verify checksums on resolve
17+
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
1718

1819
repositories {
1920
inherits true // Whether to inherit repository definitions from plugins

grails-resources/src/grails/plugin/grails-app/conf/BuildConfig.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ grails.project.dependency.resolution = {
99
// excludes 'ehcache'
1010
}
1111
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
12+
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
1213
repositories {
1314
grailsCentral()
1415
// uncomment the below to enable remote dependency resolution

0 commit comments

Comments
 (0)