Created
January 31, 2017 18:02
-
-
Save dam5s/2089702e3d4bf29869babcce76c67bab to your computer and use it in GitHub Desktop.
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
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