is this lazy or eager? ```tasks.compileJava { o...
# community-support
c
is this lazy or eager?
Copy code
tasks.compileJava {
  options.release = 17
  options.compilerArgs.addAll(
    listOf(
      "-AaddSuppressWarningsAnnotation=true",
      "-AaddGeneratedAnnotation=true",
    ),
  )
}
v
Should be lazy, which part do you think is suspicious?
c
I'm suspicious of anything that doesn't use configureEach 😉
v
I see. In Groovy DSL it would be eager, as
tasks.compileJava
directly gives you the task. But as there is a trailing comma and a
listOf
, this is Kotlin DSL. In Kotlin DSL
tasks.compileJava
gives you a
TaskProvider
. And
TaskProvider.invoke
(which is what you use there implicitly) is syntactic sugar for
TaskProvider.configure
which is the lazy variant of
configureEach
for one provider.
👍 2
So if you want to be more explicit, use
tasks.compileJava.configure { ... }
, but it really is the same effectively