diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cb8f582..d9160f68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ 1.9.9 / 2014-05-xx ================== +* Bugfix: properly respect resolutionStrategy.force 'group:artifact:version' present in build.gradle * Add commitLock task 1.9.8 / 2014-05-02 diff --git a/src/main/groovy/nebula/plugin/dependencylock/DependencyLockPlugin.groovy b/src/main/groovy/nebula/plugin/dependencylock/DependencyLockPlugin.groovy index 111d4b5f..d20709af 100644 --- a/src/main/groovy/nebula/plugin/dependencylock/DependencyLockPlugin.groovy +++ b/src/main/groovy/nebula/plugin/dependencylock/DependencyLockPlugin.groovy @@ -132,10 +132,13 @@ class DependencyLockPlugin implements Plugin { logger.info("Using command line overrides ${project['dependencyLock.override']}") } - def overrideModules = overrides.collect { "${it.key}:${it.value}" } + def overrideForces = overrides.collect { "${it.key}:${it.value}" } + logger.debug(overrideForces.toString()) project.configurations.all { - resolutionStrategy.forcedModules = overrideModules + resolutionStrategy { + overrideForces.each { dep -> force dep} + } } } @@ -143,15 +146,17 @@ class DependencyLockPlugin implements Plugin { logger.info("Using ${dependenciesLock.name} to lock dependencies") def locks = loadLock(dependenciesLock) def nonProjectLocks = locks.findAll { it.value?.locked } - def forcedModules = nonProjectLocks.collect { + def lockForces = nonProjectLocks.collect { overrides.containsKey(it.key) ? "${it.key}:${overrides[it.key]}" : "${it.key}:${it.value.locked}" } def unusedOverrides = overrides.findAll { !locks.containsKey(it.key) }.collect { "${it.key}:${it.value}" } - forcedModules << unusedOverrides - logger.debug(forcedModules.toString()) + lockForces << unusedOverrides + logger.debug(lockForces.toString()) project.configurations.all { - resolutionStrategy.forcedModules = forcedModules + resolutionStrategy { + lockForces.each { dep -> force dep} + } } } diff --git a/src/test/groovy/nebula/plugin/dependencylock/DependencyLockPluginSpec.groovy b/src/test/groovy/nebula/plugin/dependencylock/DependencyLockPluginSpec.groovy index 6617a00d..f7b16231 100644 --- a/src/test/groovy/nebula/plugin/dependencylock/DependencyLockPluginSpec.groovy +++ b/src/test/groovy/nebula/plugin/dependencylock/DependencyLockPluginSpec.groovy @@ -99,6 +99,33 @@ class DependencyLockPluginSpec extends ProjectSpec { foo.moduleVersion == '2.0.1' } + def 'command line override of a dependency with forces in place'() { + stockTestSetup() + + project.dependencies { + compile 'test.example:baz:1.+' + } + + project.configurations.all { + resolutionStrategy { + force 'test.example:baz:1.0.0' + } + } + + project.ext.set('dependencyLock.override', 'test.example:foo:2.0.1') + + when: + project.apply plugin: pluginName + triggerTaskGraphWhenReady() + def resolved = project.configurations.compile.resolvedConfiguration + + then: + def foo = resolved.firstLevelModuleDependencies.find { it.moduleName == 'foo' } + foo.moduleVersion == '2.0.1' + def baz = resolved.firstLevelModuleDependencies.find { it.moduleName == 'baz' } + baz.moduleVersion == '1.0.0' + } + def 'command line overrides of multiple dependencies'() { def dependenciesLock = new File(projectDir, 'dependencies.lock') dependenciesLock << '''\