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:
parent
7a34ba35f7
commit
bcd0939b61
25
build.gradle
25
build.gradle
|
@ -584,9 +584,30 @@ allprojects {
|
|||
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 checkPart2
|
||||
tasks.matching { it.name == "check" }.all { check ->
|
||||
|
|
Loading…
Reference in New Issue