Adam
08/06/2025, 2:09 PMtaskB
depends on taskA
, but taskB
is disabled. When I run gradle taskB
, why does Gradle still run taskA
? Shouldn't it also be skipped?
val taskA by tasks.registering {
doLast {
println("running $path")
}
}
val taskB by tasks.registering {
enabled = false
onlyIf { false }
dependsOn(taskA)
doLast {
println("running $path")
}
}
./gradlew taskB
> Task :taskA
running :taskA
> Task :taskB SKIPPED
BUILD SUCCESSFUL in 175ms
Vampire
08/06/2025, 2:19 PMenabled
to false
is just skipping the work of that task and does not influence dependency tasks.Vampire
08/06/2025, 2:19 PMonlyIf { false }
Vampire
08/06/2025, 2:20 PMVampire
08/06/2025, 2:21 PM-x
by adding the task path to the StartParameters
setting, that would then work like using -x
and thus also exclude the dependency tasks.Vampire
08/06/2025, 2:21 PMXeno
08/08/2025, 8:56 AMVampire
08/08/2025, 9:10 AM