Reputation: 5843
I have a Gradle project with complex dependencies, which I can see using ./gradlew module-name:dependencies
:
[...]
testRuntimeClasspath - Runtime classpath of source set 'test'.
+--- org.apache.logging.log4j:log4j-core -> 2.11.0
| \--- org.apache.logging.log4j:log4j-api:2.11.0
+--- com.google.guava:guava -> 20.0
+--- project :xxx
| +--- org.springframework:spring-tx -> 5.1.7.RELEASE
| | +--- org.springframework:spring-beans:5.1.7.RELEASE
| | | \--- org.springframework:spring-core:5.1.7.RELEASE
| | | \--- org.springframework:spring-jcl:5.1.7.RELEASE
| | \--- org.springframework:spring-core:5.1.7.RELEASE (*)
| +--- org.springframework:spring-context -> 5.1.7.RELEASE
| | +--- org.springframework:spring-aop:5.1.7.RELEASE
| | | +--- org.springframework:spring-beans:5.1.7.RELEASE (*)
| | | \--- org.springframework:spring-core:5.1.7.RELEASE (*)
| | +--- org.springframework:spring-beans:5.1.7.RELEASE (*)
| | +--- org.springframework:spring-core:5.1.7.RELEASE (*)
| | \--- org.springframework:spring-expression:5.1.7.RELEASE
| | \--- org.springframework:spring-core:5.1.7.RELEASE (*)
[...]
When I exclude nested dependencies and include them explicitly, the result might look like this:
[...]
testRuntimeClasspath - Runtime classpath of source set 'test'.
+--- org.apache.logging.log4j:log4j-core -> 2.11.0
| \--- org.apache.logging.log4j:log4j-api:2.11.0
+--- com.google.guava:guava -> 20.0
+--- project :xxx
| +--- org.springframework:spring-context -> 5.1.7.RELEASE
| | +--- org.springframework:spring-aop:5.1.7.RELEASE
| | | +--- org.springframework:spring-beans:5.1.7.RELEASE (*)
| | | \--- org.springframework:spring-core:5.1.7.RELEASE (*)
| | +--- org.springframework:spring-beans:5.1.7.RELEASE (*)
| | +--- org.springframework:spring-core:5.1.7.RELEASE (*)
| | \--- org.springframework:spring-expression:5.1.7.RELEASE
| | \--- org.springframework:spring-core:5.1.7.RELEASE (*)
+--- org.springframework:spring-tx -> 5.1.7.RELEASE
| +--- org.springframework:spring-beans:5.1.7.RELEASE
| | \--- org.springframework:spring-core:5.1.7.RELEASE
| | \--- org.springframework:spring-jcl:5.1.7.RELEASE
| \--- org.springframework:spring-core:5.1.7.RELEASE (*)
[...]
In order to see if the set of dependencies changed, I'd like to compare lists of dependencies. In other words, I'd like to flatten the tree view shown above, so that I can concentrate on differences that are not related to transitive inclusions.
With Maven I can do mvn dependency:tree
and mvn dependency:list
. How can I do this using Gradle?
Upvotes: 1
Views: 790
Reputation: 12086
I don't think you will find some Gradle core tasks to achieve this (maybe some community plugin exist), but you can write your own custom task
to list dependencies in any format you want ( text, csv, ...)
task dependencyList() {
doLast() {
configurations.each { configuration ->
if (configuration.isCanBeResolved()){
println("Configuration $configuration.name ================================")
def files = configuration.resolvedConfiguration.getFiles().sort()
files.forEach{ f -> println(" dep: $f.name")}
}
}
}
}
Upvotes: 1