Any hint how `val jar by tasks.getting(Jar::class)...
# kotlin-dsl
s
Any hint how
val jar by tasks.getting(Jar::class)
behaves if there are multiple Jar tasks in the project? I could not find any docs on that.
Ok, https://docs.gradle.org/current/kotlin-dsl/gradle/org.gradle.kotlin.dsl/getting.html[…]rphicDomainObjectContainerGettingDelegateProvider%3CT,%20U%3E sounds as if all matching tasks are returned. I was assuming the function to only return one task (provider).
p
It’s only one task: the jar named task
πŸ‘† 1
s
Ah, so the name "jar" is inferred from the variable name due to
by
?
βœ… 1
πŸ‘ 1
Thanks!
p
Yes
But you should use the named variant to not create the task, named is lazy.
s
Like
val jar by tasks.named<Jar>("jar")
?
c
val jar = tasks.named<Jar>("jar")
πŸ‘ 1
p
That requires passing the name, I mean by existing
πŸ‘† 1