This message was deleted.
# community-support
s
This message was deleted.
a
in practice there’s no difference, they’re both fancy ways of fetching an element from a NamedDomainObjectContainer if you dig through the source you’ll eventually see that both effectively do this:
Copy code
sourceSets.named<org.gradle.api.tasks.SourceSet>("main")
the only difference might have an impact is the second one requires the type-safe model accessors are present, which is only true in
build.gradle.kts
files (or precompiled plugin scripts)
s
okay, perfect. thanks for digging 🙂
👍 1
e
they're not equivalent in other ways:
Copy code
val main by getting
main.java...
is equivalent to
Copy code
getByName("main").java...
which is eager,
Copy code
main { java... }
is equivalent to
Copy code
named("main") { java... }
which is lazy
if you used
Copy code
val main by existing
main.configure { java... }
then that would be lazy
doesn't make a practical difference for
sourceSets
but it can for other types of object collections