This message was deleted.
# community-support
s
This message was deleted.
c
Not generally. SourceSets are almost always materialized. Lazy is good for tasks, where not all of them are always configured.
e
Thanks. I wish the APIs indicated that organically, i.e. only have lazy APIs for tasks, etc... I know there's some kind of plan for that, but I wish it would happen already.
c
ideally the API would be only the lazy stuff as its very confusing with all kinds of methods.
v
While there is no real reason to use the lazy api with source sets currently, there could be real reason to do it in the future when maybe more things become lazy. The main question is, what would be the reason to use the eager api? Usage-wise they are practically the same regarding bluntness or boilerplate or whatever, you just use different methods. So just always use the lazy API and you should also be fine and don't need to think about which to use. I don't think that should have any significant negative impact?
e
I ask because the Kotlin property delegates use the eager API
v
Where?
Copy code
val org.gradle.api.tasks.SourceSetContainer.`main`: NamedDomainObjectProvider<org.gradle.api.tasks.SourceSet>
    get() = named<org.gradle.api.tasks.SourceSet>("main")
named
is not eager, it is lazy
e
NamedDomainObjectCollectionDelegateProvider
uses
getByName
v
What's your point?
e
I'm using it 😅
v
I don't see it
How do you get to that class?
You said the source set accessors are eager
But I showed you the accessor code and it only uses lazy api
e
Copy code
java {
    sourceSets {
        val test by getting {
            java.srcDir("../common-jvm/src/test/java")
        }
    }
}
I didn't say it was the accessors, I said it was the Kotlin property delegates
v
"by getting" is eager, yes
"by existing" is the lazy variant
Oh, sorry, misunderstood
So yeah, "by getting" is just the eager variant like using "getByName", "by existing" is the lazy variant like using "named"
e
Awesome, TIL, thanks
v
Also
Copy code
java {
    val test by sourceSets {
        java.srcDir("../common-jvm/src/test/java")
    }
}
would be the eager variant, it is practiaclly the same as
Copy code
java {
    val test by sourceSets.getting {
        java.srcDir("../common-jvm/src/test/java")
    }
}
and the same as your snippet
👍 1