This message was deleted.
# community-support
s
This message was deleted.
c
Reading the docs I don't see the difference
I expected all to be "worst" (for example only consuming elements added before it's invoked) but it seems it's not:
Executes the given action against all objects in this collection, and any objects subsequently added to this collection.
e
.all
is eager - it runs immediately on existing objects, as well as being configuring future objects as soon as they are added
whereas
.configureEach
is lazy - it runs when each object is configured, instead of as soon as it is registered
https://docs.gradle.org/current/userguide/task_configuration_avoidance.html#sec:old_vs_new_configuration_api_overview
Instead of:
DomainObjectCollection.all(org.gradle.api.Action)
Use:
DomainObjectCollection.configureEach(org.gradle.api.Action)
c
That's what I expected...but then..maybe the docs need to mention it. 🤔
e
it could probably be stated more clearly, but https://docs.gradle.org/current/javadoc/org/gradle/api/DomainObjectCollection.html
void all(Action<? super T> action)
Executes the given closure against all objects in this collection, and any objects subsequently added to this collection.
void configureEach​(Action<? super T> action)
Configures each element in this collection using the given action, as each element is required.
already implies that configureEach is lazier than all
c
Meh, I would say it's unclear
e
Took me a while to find this. It would be nice if there was something that would steer us towards the correct API to use. Maybe soft deprecating the existing eager APIs and providing a new one with clearer naming. https://gradle-community.slack.com/archives/CAHSN3LDN/p1649442110194519?thread_ts=1649440291.522169&amp;cid=CAHSN3LDN
e
Well now I feel stupid considering I already upvoted that issue 😆