Created
June 28, 2018 03:44
-
-
Save nikialeksey/7cefae6b3104ce9a2c765197343bc436 to your computer and use it in GitHub Desktop.
Gradle: multi-project dependency graph (supports depth > 2, supports gradle 4.4+)
This file contains 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/tzachz/419478fc8b009e953f5e5dc39f3f3a2a | |
// 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 << "strict 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 | |
.collectMany { it.allDependencies } | |
.findAll { it instanceof ProjectDependency } | |
.each { to -> file << ("\"${project.name}\" -> \"${to.name}\"\n")} | |
project.childProjects.each { name, childProject -> printDeps(file, childProject) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @nikialeksey
I think it might be better to insert
Collections#unique
afterfindAll
because the achieved file will be much simpler :)