Created
October 22, 2015 03:08
-
-
Save ftclausen/c82015d6669888772f4d to your computer and use it in GitHub Desktop.
What breaks the lock file generation?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/gradle.properties b/gradle.properties | |
index 48c940f..cf19926 100644 | |
--- a/gradle.properties | |
+++ b/gradle.properties | |
@@ -1 +1 @@ | |
-version=2.2.2 | |
+version=2.2.3 | |
diff --git a/src/main/groovy/nebula/plugin/dependencylock/DependencyLockPlugin.groovy b/src/main/groovy/nebula/plugin/dependencylock/DependencyLockPlugin.groovy | |
index 81a5466..eb6125d 100644 | |
--- a/src/main/groovy/nebula/plugin/dependencylock/DependencyLockPlugin.groovy | |
+++ b/src/main/groovy/nebula/plugin/dependencylock/DependencyLockPlugin.groovy | |
@@ -246,6 +246,7 @@ class DependencyLockPlugin implements Plugin<Project> { | |
def subprojects = project.subprojects.collect { project.dependencies.create(it) } | |
def subprojectsArray = subprojects.toArray(new Dependency[subprojects.size()]) | |
def conf = project.configurations.detachedConfiguration(subprojectsArray) | |
+ project.allprojects.each { it.configurations.add(conf) } | |
[conf] | |
} | |
@@ -307,13 +308,16 @@ class DependencyLockPlugin implements Plugin<Project> { | |
// If the user specifies an override that does not exist in the lock file, force that dependency anyway. | |
def unusedOverrides = overrides.findAll { !locks.containsKey(it.key) }.collect { "${it.key}:${it.value}" } | |
- lockForces << unusedOverrides | |
- logger.debug(lockForces.toString()) | |
+ lockForces.addAll(unusedOverrides) | |
+ logger.debug('lockForces: {}', lockForces) | |
+ | |
+ // Create the dependencies explicitly to avoid doing that implicitly for every configuration | |
+ lockForces = lockForces.collect { dep -> project.dependencies.create(dep) } | |
// Pretty nice after all that work (: | |
project.configurations.all { | |
resolutionStrategy { | |
- lockForces.each { dep -> force dep} | |
+ force lockForces.toArray() | |
} | |
} | |
} | |
diff --git a/src/test/groovy/nebula/plugin/dependencylock/DependencyLockLauncherSpec.groovy b/src/test/groovy/nebula/plugin/dependencylock/DependencyLockLauncherSpec.groovy | |
index ac592de..7041e71 100644 | |
--- a/src/test/groovy/nebula/plugin/dependencylock/DependencyLockLauncherSpec.groovy | |
+++ b/src/test/groovy/nebula/plugin/dependencylock/DependencyLockLauncherSpec.groovy | |
@@ -385,6 +385,61 @@ class DependencyLockLauncherSpec extends IntegrationSpec { | |
dependencyLock { | |
includeTransitives = true | |
} | |
+ configurations.all { | |
+ resolutionStrategy { | |
+ force 'test.example:foo:2.0.1' | |
+ } | |
+ } | |
+ """.stripIndent() | |
+ | |
+ when: | |
+ runTasksSuccessfully('generateGlobalLock') | |
+ | |
+ then: | |
+ String globalLockText = '''\ | |
+ { | |
+ "test.example:bar": { "locked": "1.1.0", "transitive": [ "test.example:transitive", "test:sub1" ] }, | |
+ "test.example:baz": { "locked": "1.0.0", "transitive": [ "test.example:foobaz" ] }, | |
+ "test.example:foo": { "locked": "2.0.1", "transitive": [ "test.example:bar", "test.example:foobaz", "test:sub1" ] }, | |
+ "test.example:foobaz": { "locked": "1.0.0", "transitive": [ "test.example:transitive" ] }, | |
+ "test.example:transitive": { "locked": "1.0.0", "transitive": [ "test:sub2" ] }, | |
+ "test:sub1": { "project": true }, | |
+ "test:sub2": { "project": true } | |
+ } | |
+ '''.stripIndent() | |
+ new File(projectDir, 'build/global.lock').text == globalLockText | |
+ } | |
+ | |
+ def 'create global lock in multiproject with force in subproject'() { | |
+ addSubproject('sub1', """\ | |
+ dependencies { | |
+ compile 'test.example:bar:1.1.0' | |
+ compile 'test.example:foo:2.0.0' | |
+ } | |
+ """.stripIndent()) | |
+ addSubproject('sub2', """\ | |
+ dependencies { | |
+ compile 'test.example:transitive:1.+' | |
+ } | |
+ configurations.all { | |
+ resolutionStrategy { | |
+ force 'test.example:foo:2.0.1' | |
+ } | |
+ } | |
+ """.stripIndent()) | |
+ | |
+ buildFile << """\ | |
+ allprojects { | |
+ ${applyPlugin(DependencyLockPlugin)} | |
+ group = 'test' | |
+ } | |
+ subprojects { | |
+ apply plugin: 'java' | |
+ repositories { maven { url '${Fixture.repo}' } } | |
+ } | |
+ dependencyLock { | |
+ includeTransitives = true | |
+ } | |
""".stripIndent() | |
when: | |
@@ -395,7 +450,7 @@ class DependencyLockLauncherSpec extends IntegrationSpec { | |
{ | |
"test.example:bar": { "locked": "1.1.0", "transitive": [ "test.example:transitive", "test:sub1" ] }, | |
"test.example:baz": { "locked": "1.0.0", "transitive": [ "test.example:foobaz" ] }, | |
- "test.example:foo": { "locked": "2.0.0", "transitive": [ "test.example:bar", "test.example:foobaz", "test:sub1" ] }, | |
+ "test.example:foo": { "locked": "2.0.1", "transitive": [ "test.example:bar", "test.example:foobaz", "test:sub1" ] }, | |
"test.example:foobaz": { "locked": "1.0.0", "transitive": [ "test.example:transitive" ] }, | |
"test.example:transitive": { "locked": "1.0.0", "transitive": [ "test:sub2" ] }, | |
"test:sub1": { "project": true }, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 16 seems to be what breaks lock file generation