I posted this question on SO but did not get an answer yet.
I want to add tests of all flavors to a meta task. This does not work:
subprojects {
task("testAllFlavors"){
val buildTask = this
tasks.matching {
name.startsWith("test") && name.endsWith("DebugUnitTest")
}.all {
buildTask.dependsOn(this)
}
}
And this also does not work:
subprojects {
task("testAllFlavors"){
setDependsOn(tasks.matching {
name.startsWith("test") && name.endsWith("DebugUnitTest")
})
}
}
But this does work:
subprojects {
task("testAllFlavors"){
val buildTask = this
tasks.all {
if(name.startsWith("test") && name.endsWith("DebugUnitTest")) {
buildTask.dependsOn(this)
}
}
}
}
What is the difference between the 3 options? The look the same to me? Why does just the third option work ? I use gradle 7.1 and AGP 4.2