Thomas Broyer
04/17/2025, 3:20 PMval myConf = configurations.create("conf")
/* eager configuration */
myConf.… = …
tasks.register<MyTask>("myTask") {
someProp.from(myConf)
}
to
val myConfProvider = configurations.register("conf") {
/* lazy configuration */
… = …
}
tasks.register<MyTask>("myTask") {
someProp.from(myConfProvider)
}
and
configurations["someConf"].extendsFrom(myConf)
to
configurations.named("someConf") { extendsFrom(myConfProvider.get()) }
?Vampire
04/18/2025, 2:03 AMextendsFrom
should accept a provider.
Other than that it basically is the same as with task-configuration avoidance.
Gradle (hopefully everywhere) treats them as lazy as possible now.
And as long as your build script and your plugins do not cause eager realization you will benefit from it.
That said, there are quite some plugins that do not yet treat configurations lazy properly right now as Gradle used to also not do it.
For example https://discuss.gradle.org/t/configuration-phase-ordering-and-laziness-help-with-project-extensions/50762/20 discovers several such cases in KGP and in JVM dependency conflict resolution plugin.Vampire
04/18/2025, 2:04 AMThomas Broyer
04/18/2025, 6:41 AMGradle (hopefully everywhere) treats them as lazy as possible now.That's far from being the case though. The
java-base
plugin uses `create`/`maybeCreate` and getByName
everywhere:
https://github.com/gradle/gradle/blob/v8.14.0-RC2/platforms/jvm/plugins-java-base/src/main/java/org/gradle/api/plugins/JavaBasePlugin.javaMartin
04/18/2025, 8:26 AMVampire
04/18/2025, 9:46 AMThat's far from being the case though. The java-base plugin uses create/maybeCreate and getByName everywhere:
Well, maybe this gets improved in the future, or there are good reasons to eagerly realize those configurations. 🤷♂️ The 8.14 release notes say
Similar to tasks, configurations are now realized only when necessary.
and
This change can reduce configuration time and memory usage in some builds.
Martin
04/18/2025, 9:49 AMextendsFrom()
calls? Adding dependencies? That should probably execute in nanoseconds on modern hardware...Thomas Broyer
04/18/2025, 9:51 AMjava-base
plugin) so these might be the projects they're talking about here.Philip W
04/18/2025, 11:12 AM