Skip to content

Instantly share code, notes, and snippets.

@dam5s
Created January 31, 2017 18:02
Show Gist options
  • Save dam5s/2089702e3d4bf29869babcce76c67bab to your computer and use it in GitHub Desktop.
Save dam5s/2089702e3d4bf29869babcce76c67bab to your computer and use it in GitHub Desktop.
task dependenciesGraphDot {
mustRunAfter "clean"
def graphBuildDir = "build/dependenciesGraph"
def dotFile = file "$graphBuildDir/graph.dot"
doLast {
delete graphBuildDir
mkdir graphBuildDir
dotFile << "digraph dependencies {\n"
project.subprojects.forEach { Project subProject ->
try {
Configuration compileConfig = subProject.configurations["compile"]
compileConfig
.dependencies
.grep { it.respondsTo("getDependencyProject") }
.forEach { dotFile << """ "$subProject.name" -> "$it.dependencyProject.name"\n""" }
} catch (UnknownConfigurationException ignored) {
}
}
dotFile << "}\n"
}
}
configure(dependenciesGraphDot) {
group = 'DependenciesGraph'
description = 'Generate DOT file'
}
task dependenciesGraph(dependsOn: "dependenciesGraphDot", type: Exec) {
workingDir "$project.buildDir/dependenciesGraph"
commandLine "dot", "-O", "-Tpng", "graph.dot"
}
configure(dependenciesGraph) {
group = 'DependenciesGraph'
description = 'Generate PNG file'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment