-
-
Save risadams/cb1bba9e69804b2f8fb0656f26106973 to your computer and use it in GitHub Desktop.
Mermaid visualization of a Gradle project's task graph
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
gradle.taskGraph.whenReady { | |
println '' | |
println '----------------------------------------' | |
println '' | |
println 'Generating Task Graph:' | |
def mermaid = new File(rootProject.buildDir, 'project.mermaid') | |
mermaid.delete() | |
def command = "./gradlew " + gradle.startParameter.getTaskNames().join(" ") | |
println "command: " + command | |
def projectTaskMap = [:] //Collapse Duplicates | |
mermaid << 'graph TD\n' | |
gradle.taskGraph.allTasks.each { task -> | |
task.taskDependencies.getDependencies(task).each { dep-> | |
projectTaskMap["${dep.name} --> ${task.name}"] = "" | |
} | |
} | |
projectTaskMap.each { | |
mermaid << "$it.key\n" | |
} | |
mermaid << '\n' | |
println("Visualized Task graph created at ${mermaid.absolutePath}.mermaid") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment