Skip to content

Instantly share code, notes, and snippets.

@tevjef
Forked from tzachz/dependency-report.gradle
Created February 11, 2018 01:04
Show Gist options
  • Save tevjef/6a085e244303a86c8738ab89afa1becc to your computer and use it in GitHub Desktop.
Save tevjef/6a085e244303a86c8738ab89afa1becc to your computer and use it in GitHub Desktop.
Gradle: multi-project dependency graph (supports depth > 2)
task moduleDependencyReport {
doLast {
def file = new File("project-dependencies.dot")
file.delete()
file << "digraph {\n"
file << "splines=ortho\n"
printDeps(file, rootProject)
file << "}\n"
}
}
// recursively print dependencies to file and move on to child projects
def printDeps(file, project) {
project.configurations.each {
it.dependencies
.matching { it in ProjectDependency }
.each { to -> file << ("\"${project.name}\" -> \"${to.name}\"\n") }
}
project.childProjects.each { child -> printDeps(file, child.value) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment