Hello,
I have a very simple gradle build file which declares the following dependencies:
dependencies {
compile("ca.uhn.hapi.fhir:hapi-fhir-testpage-overlay:2.0:classes@jar") {
transitive = false
}
compile("ca.uhn.hapi.fhir:hapi-fhir-testpage-overlay:2.0@war") {
transitive = false
}
}
When printing dependencies tree with dependencies task, it prints:
compile - Dependencies for source set 'main'. a single dependency
\--- ca.uhn.hapi.fhir:hapi-fhir-testpage-overlay:2.0
Whereas the very same maven setup would report:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ test ---
[INFO] test:test:jar:1.0
[INFO] +- ca.uhn.hapi.fhir:hapi-fhir-testpage-overlay:jar:classes:2.0:compile
[INFO] \- ca.uhn.hapi.fhir:hapi-fhir-testpage-overlay:war:2.0:compile
Looks like gradle conflates the deps as they have the same gav and ignores different type and classifier.
Am I doing something wrong ?
Chris_Dore
(Chris Doré)
October 24, 2016, 6:40pm
2
The resolved configuration still contains both artifacts for the dependency.
For example, this task:
task dumpConfig << {
println configurations.compile.files.join( '\n' )
}
produces:
$ ./gradlew dumpConfig
:dumpConfig
/home/cdore/.gradle/caches/modules-2/files-2.1/ca.uhn.hapi.fhir/hapi-fhir-testpage-overlay/2.0/ff5421ee095f0cac07a93a07053b4f384ac874ab/hapi-fhir-testpage-overlay-2.0-classes.jar
/home/cdore/.gradle/caches/modules-2/files-2.1/ca.uhn.hapi.fhir/hapi-fhir-testpage-overlay/2.0/94cf8d1d289172936e32639ed24e4db9645b0b4c/hapi-fhir-testpage-overlay-2.0.war
I updated the task as follow:
task dumpConfig {
doLast {
configurations.compile.files.each {
println "File: " + it
}
configurations.compile.allDependencies.each {
println "Dep1: " + it
}
configurations.compile.incoming.resolutionResult.allDependencies.each {
println "Dep2: " + it
}
configurations.compile.incoming.resolutionResult.root.dependencies.each {
println "Dep3: " + it
}
}
}
It prints:
$ ./gradlew dumpConfig
:dumpConfig
File: /opt/sfw/tools/apache/maven-repo/ca/uhn/hapi/fhir/hapi-fhir-testpage-overlay/2.0/hapi-fhir-testpage-overlay-2.0-classes.jar
File: /opt/sfw/tools/apache/maven-repo/ca/uhn/hapi/fhir/hapi-fhir-testpage-overlay/2.0/hapi-fhir-testpage-overlay-2.0.war
Dep1: DefaultExternalModuleDependency{group='ca.uhn.hapi.fhir', name='hapi-fhir-testpage-overlay', version='2.0', configuration='default'}
Dep1: DefaultExternalModuleDependency{group='ca.uhn.hapi.fhir', name='hapi-fhir-testpage-overlay', version='2.0', configuration='default'}
Dep2: ca.uhn.hapi.fhir:hapi-fhir-testpage-overlay:2.0
Dep3: ca.uhn.hapi.fhir:hapi-fhir-testpage-overlay:2.0
I’m using configurations.$name.incoming.resolutionResult.root
to inspect deps and do some things with them so my plugin fails with such configuration as one of the deps is missing. Is there a nice/better way to collect all the information about resolved dependencies (GAV, classifier, type and file) ?