It’s a close call for sure.
a.) this is closer to how I configure other parts, for example tests
tasks.test {
useJUnitPlatform()
}
b.) I sometimes find myself helping the IDE/Kotlin compiler to figure out the right generic type. This happens for example when using some AssertJ matchers in Kotlin code. It’s logical for me, that this helps to clarify the type of this
within the block.
But again, just personal preference.
Btw. I think tasks.getByName
should be avoided in larger Gradle configurations, as I think it doesn’t allow configuration avoidance.