Created
May 31, 2023 10:02
-
-
Save cies/378dfbbe4080fb69bcda43f3610956f8 to your computer and use it in GitHub Desktop.
Make Gradle print its task plan
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
// This prints the dependencies of each task in the current execution graph | |
gradle.taskGraph.whenReady( | |
closureOf<TaskExecutionGraph> { | |
println("About to run ${allTasks.size} tasks: (use `-i` to see why tasks are skipped, use `--rerun-tasks` to prevent UP-TO-DATE checks)") | |
allTasks.forEachIndexed { i, task -> | |
val dependenciesString = | |
if (task.dependsOn.isEmpty()) { | |
"" | |
} else { | |
task.dependsOn.joinToString(", ", " (depends on ", ")") { dependency -> | |
dependency.toString().let { | |
if (it.startsWith("provider")) { | |
it.split("'")[1] | |
} else if (it.contains(" dirs")) { | |
"[$it]" | |
} else { | |
":${it.removePrefix(":")}" | |
} | |
} | |
} | |
} | |
println("${(i + 1).toString().padStart(5)}. :${task.name}$dependenciesString") | |
} | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment