Sunday, April 10, 2016

Print Gradle Dependencies

One way to print the project's Gradle dependencies is 'gradle dependencyReport'.
However it creates a very large file with many scopes that are sometimes hard to track.
Sometimes it can be useful just to print the list of dependencies of a specific scope.
A very small script can do the job, and here are some examples:

// Runtime
task printRuntimeDependencies << {
project.configurations.runtime.each {
file -> println(file)
}
}
// Compile
task printCompileDependencies << {
project.configurations.compile.each {
file -> println(file)
}
}
// Compile SubModule
task printCompileDependencies << {
project(':main').configurations.compile.each {
file -> println(file)
}
}
view raw build.gradle hosted with ❤ by GitHub

No comments: