-
-
Save keeganwitt/9f9d82ae2a37029d3aed91f0672341f6 to your computer and use it in GitHub Desktop.
Gradle: multi-project dependency graph (supports depth > 2)
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
// 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) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment