Created
July 26, 2017 09:10
-
-
Save matthiasbalke/887f44c45de3d7a8ebc4d5f9f219c210 to your computer and use it in GitHub Desktop.
List all Gradle Dependencies
This file contains hidden or 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