Skip to content

Instantly share code, notes, and snippets.

@tzachz
Created November 17, 2016 14:37
Show Gist options
  • Save tzachz/419478fc8b009e953f5e5dc39f3f3a2a to your computer and use it in GitHub Desktop.
Save tzachz/419478fc8b009e953f5e5dc39f3f3a2a to your computer and use it in GitHub Desktop.
Gradle: multi-project dependency graph (supports depth > 2)
// Inspired by https://gist.github.com/abesto/cdcdd38263eacf1cbb51
// Task creates a .dot file with all inter-module dependencies
// Supports any depth of nested modules
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.compile.dependencies
.matching { it in ProjectDependency }
.each { to -> file << ("\"${project.name}\" -> \"${to.name}\"\n")}
project.childProjects.each { child -> printDeps(file, child.value) }
}
@nikialeksey
Copy link

Thanks, but it is not working with new Android projects on gradle 4.4. If you need new android projects support try this one: https://gist.github.com/nikialeksey/7cefae6b3104ce9a2c765197343bc436

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment