I want to get information of all dependencies (including transitive ones) in a gradle task.
I tried the code:
class MyGradlePlugin implements Plugin<Project> {
void apply(Project project) {
project.afterEvaluate {
println " Project:" + project.name
project.configurations.each { conf ->
println " Configuration: ${conf.name}"
conf.allDependencies.each { dep ->
println " ${dep.group}:${dep.name}:${dep.version}"
}
}
}
}
}
But it only prints the declared ones, no transitive ones.
That means, if my dependencies
is:
dependencies {
compile "com.google.guava:guava:18.0"
compile 'org.codehaus.groovy:groovy-all:2.3.11'
testCompile 'junit:junit:4.11'
}
It only prints these 3 dependencies, but the org.hamcrest:hamcrest-core:1.3
which is the transitive dependency of junit:junit:4.11
is not displayed.
How to modify the code to let it show org.hamcrest:hamcrest-core:1.3
as well?
PS: I know gradle dependencies
task will show everything I want, but I need to get the dependencies information manually and print it in my own format.
Finally, I figure it out with follow task