Skip to content

Instantly share code, notes, and snippets.

@satyagraha
Created April 22, 2014 09:37
Show Gist options
  • Save satyagraha/11172010 to your computer and use it in GitHub Desktop.
Save satyagraha/11172010 to your computer and use it in GitHub Desktop.
Gradle-Graphviz 1
task showConfigurations << {
new File("graph/configurations.dot").withWriter { out ->
out.println "digraph configurations {"
out.println "rankdir=BT;"
configurations.all { con ->
out.println "${con.name} [shape=box];"
con.extendsFrom.each { ext ->
out.println "${con.name} -> ${ext.name};"
}
}
out.println "}"
}
}
task showDependencies << {
configurations.all { con ->
new File("graph/dep.${con.name}.dot").withWriter { out ->
def showDeps = { Configuration c ->
out.println "subgraph cluster_${c.name} {"
out.println "graph[rankdir=TB,style=dashed,label=${c.name},labelloc=b,labeljust=l,labelstyle=bold];"
out.println "${c.name} [shape=point,style=invis];"
out.println "node[color=none,shape=plaintext];"
deps = c.dependencies.collect { dep ->
"${dep.group}:${dep.name}:${dep.version}"
}
out.println "\"" + deps.join("\\n") + "\";"
out.println "}"
}
out.println "digraph ${con.name} {"
out.println "graph[rankdir=BT,compound=true,nodesep=2,ranksep=1];"
showDeps con
con.hierarchy.each { hier ->
showDeps hier
hier.extendsFrom.each { ext ->
out.println "${hier.name} -> ${ext.name} [ltail=cluster_${hier.name},lhead=cluster_${ext.name}];"
}
}
out.println "}"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment