Skip to content

Instantly share code, notes, and snippets.

@andhikayuana
Forked from matthiasbalke/allDependencies.gradle
Created October 26, 2021 08:20
Show Gist options
  • Save andhikayuana/fec2e050b0d28d91e4d9192df8fa0b82 to your computer and use it in GitHub Desktop.
Save andhikayuana/fec2e050b0d28d91e4d9192df8fa0b82 to your computer and use it in GitHub Desktop.
List all Gradle Dependencies
/**
* 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