What's the idiomatic way to configure a task by na...
# community-support
m
What's the idiomatic way to configure a task by name if A) it already exists, or B) it's added later, but without crashing if it's not added at all? E.g., with plugins we have
pluginManager.withPlugin
. For tasks, I'm thinking
tasks.matching{ it.name == "sourcesJar" }.configureEach {...}
? Is this lazy enough?
v
Yes, or
tasks.named { it == "sourcesJar" }.configureEach { ... }
if you don't need to support Gradle version not yet having the
named { ... }
variant
👍 1
8.6 added
named { ... }