Add a rule for task dependencies (#41322)

This commit adds a task rule to print the task dependencies of any task.
It only prints the direct dependencies, but makes debugging missing
dependencies a lot easier.
This commit is contained in:
Ryan Ernst 2019-04-19 09:49:36 -07:00
parent 7a34ba35f7
commit bcd0939b61
1 changed files with 23 additions and 2 deletions

View File

@ -584,9 +584,30 @@ allprojects {
configurations.findAll { it.isCanBeResolved() }.each { it.resolve() } configurations.findAll { it.isCanBeResolved() }.each { it.resolve() }
} }
} }
}
allprojects { // helper task to print direct dependencies of a single task
project.tasks.addRule("Pattern: <taskName>Dependencies") { String taskName ->
if (taskName.endsWith("Dependencies") == false) {
return
}
if (project.tasks.findByName(taskName) != null) {
return
}
String realTaskName = taskName.substring(0, taskName.length() - "Dependencies".length())
Task realTask = project.tasks.findByName(realTaskName)
if (realTask == null) {
return
}
project.tasks.create(taskName) {
doLast {
println("${realTask.path} dependencies:")
for (Task dep : realTask.getTaskDependencies().getDependencies(realTask)) {
println(" - ${dep.path}")
}
}
}
}
task checkPart1 task checkPart1
task checkPart2 task checkPart2
tasks.matching { it.name == "check" }.all { check -> tasks.matching { it.name == "check" }.all { check ->