-
-
Save andhikayuana/fec2e050b0d28d91e4d9192df8fa0b82 to your computer and use it in GitHub Desktop.
List all Gradle Dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* List all Dependencies of main / subprojects for given configurations. | |
*/ | |
task allDependencies { | |
doLast { | |
// only check defined configurations | |
def includedConfigurations = ['compile', 'testCompile', 'runtime'] | |
def deps = [:] | |
allprojects.each { p -> | |
p.configurations.all.findAll { | |
!it.allDependencies.empty && includedConfigurations.contains(it.name) | |
}.each { config -> | |
// create a SortedSet per configuration | |
if (!deps.containsKey(config.name)) { | |
deps[config.name] = [] as SortedSet | |
} | |
// add dependencies to matching set | |
config.allDependencies.each { dep -> | |
deps[config.name].add("$dep.group:$dep.name:$dep.version") | |
} | |
} | |
} | |
// print sorted dependencies per configuration | |
deps.each { config, configDeps -> | |
println " ${config} ".center(60, '-') | |
configDeps.each { dep -> | |
println dep | |
} | |
println "-" * 60 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment