I know that Gradle has the excellent dependencies
task that lists out all dependencies for a project. However, it returns them in a tree listing.
I would like to get a list of all my dependencies as they are resolved in just a flat list. Similar to how the Maven dependency plugin list
goal behaves.
Here is a short task that meets that need:
task('dependenciesList') << {
println "Compile dependencies"
def selectedDeps = project.configurations.compile.incoming.resolutionResult.allDependencies.collect { dep ->
"${dep.selected}"
}
selectedDeps.unique().sort().each { println it}
}
The third line is the interesting part. You need to get the configuration you care about (compile) then insead of getting dependencies there, the incoming.resolutionResult
will provide the resolved values and versions.
You can flatten the deps tree using sed|sort|uniq in linux or cygwin:
$ gradle dependencies | sed 's/^.* //' | sort | uniq