Hi,
I’ve encountered a strange scenario that I’m not sure how to work around, and I think could possibly be a bug (or in need of improvement).
Given the following build.gradle:
task wrapper(type: Wrapper) {
gradleVersion = '2.13'
}
allprojects {
apply plugin: 'java'
}
subprojects {
configurations {
otherConfig
otherConfig2
}
task otherJar( type: Jar ) {
classifier 'other'
}
task otherJar2( type: Jar ) {
classifier 'other2'
}
artifacts {
otherConfig otherJar
otherConfig2 otherJar2
}
}
repositories {
jcenter()
}
configurations.compile.resolutionStrategy {
dependencySubstitution {
substitute module('org.hamcrest:hamcrest-core') with project(':subproject')
//this however works as I would expect:
//substitute module('junit:junit') with project(':subproject')
}
}
dependencies {
compile 'junit:junit:+'
}
task useFiles {
inputs.files configurations.compile
doLast {
configurations.compile.each {
println "dep ${it}"
}
}
}
and settings.gradle:
include ':subproject'
The output of the useFiles task are a bit unexpected:
:useFiles
dep /home/cdore/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar
dep /home/cdore/gradle-configartifacts-test/subproject/build/libs/subproject.jar
dep /home/cdore/gradle-configartifacts-test/subproject/build/libs/subproject-other2.jar
dep /home/cdore/gradle-configartifacts-test/subproject/build/libs/subproject-other.jar
If instead you substitute the first level dependency (junit in my example):
:useFiles
dep /home/cdore/gradle-configartifacts-test/subproject/build/libs/subproject.jar
Why is Gradle adding all artifacts of subproject to the compile configuration when substituting the transitive dependency?
Thanks, Chris