I recently found this regression in v2.5 up to v2.8. I believe it worked in v2.3.
The basic issue is that the getResolvedConfiguration
method will fail if an extraneous configuration is not correctly defined. This happens in my multi-project build in cases where only a subset of projects are available. In some cases a user may only have a subset of the multi-project build due to partitioning of our code features.
Here is a code sample that demonstrates the issue:
apply plugin:'java'
repositories { mavenCentral() }
configurations { ignoreThis }
dependencies {
compile 'commons-lang:commons-lang:2.4'
ignoreThis project( path:':doesNotExist', configuration:'none')
}
task resolve << {
configurations.compile.resolvedConfiguration
.resolvedArtifacts*.moduleVersion.id
.flatten()
.each() { println it }
}
With settings.gradle set to:
include 'doesNotExist'
Running the build returns:
$ gradle resolve
:resolve FAILED
FAILURE: Build failed with an exception.
* Where:
Build file '/home/pcm/temp/gradleresolve/build.gradle' line: 13
* What went wrong:
Execution failed for task ':resolve'.
> Could not resolve all dependencies for configuration ':compile'.
> Configuration with name 'none' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.314 secs
The resolve
task should ignore the doesNotExist
since it is not referenced in the compile
configuration.