In 8.6
Previously, filtering tasks by name required using the
matching
method using the following pattern:
tasks.matching { it.name.contains("pack") }.configureEach {
// configure details of all '*pack*' tasks that are part of the task graph
}
The problem was that calling matching
triggered the creation of all tasks, even when the task was not part of the build execution.
End of quote
I don’t understand this paragraph. tasks.matching { }.configureEach { } doesn’t trigger creation of all tasks.
The sample code demonstrate it:
// https://docs.gradle.org/current/release-notes.html
class TX extends DefaultTask {
TX() {
println "Task ${this} was created"
}
}
tasks.register("t1", TX) {
println "${it} is configured"
}
tasks.register("t2", TX){
println "${it} is configured"
}
tasks.register("t3", TX){
println "${it} is configured"
}
// causes all to be realized, because you configured the instance
tasks.matching { Task s ->
return s.name.startsWith("t")
}.configureEach {
println "Configure in 'matching' ${it}"
}
When executing “t1” , then it is the only one that is created/configured.
What do I miss ?
Thanks
Boaz