Is there any new information about "lazy propertie...
# declarative-gradle
j
Is there any new information about "lazy properties" to allow creating DSL in Gradle Declarative to apply plugins or create tasks conditionally without ordering issues? It would be nice if this issue was solved in Declarative Gradle, as currently even you can get it more or less working, sometimes you are forced to use
afterEvaluate
as the workaround which is bad.
a
If you are thinking about core plugins having lazy properties: that effort was postponed to Gradle 10.0 due to UX concerns
j
Not about Gradle plugins themself using the current existing lazy properties but a new kind of lazy configuration property (or some alternative), to apply plugins conditionally and not having ordering issues:
Copy code
if (someProp.get() == “
true) pluginManager.apply(…)

// later
someProp.set(false)

// the property was already checked in configuration phase and it is not going to be rechecked later to “un-apply” the plugin.
a
Oh ok, I don't know of any such plans. And for Declarative Gradle the idea is to apply all plugins in a settings.gradle unconditionally and then "software features" are enabled per project when used in project build files afaik.
☝️ 2
j
Need to recheck then 👀
p
Not all plugins are applied in settings. The plugins providing the software types are applied in settings. What's done upfront with declarative is bring all project plugins in the classpath early so there's only one build classpath for all projects. Then software type project plugins can apply other project plugins. That's where Javi's question is at play.
We acknowledge that there is something missing here. All our prototype plugins rely on
afterEvaluate
in some form. It's one of the topic we have on the short list of things we need to address next.
👀 1
thank you 1
j
Nice! Thank you for the info 🙂
@Paul Merlin I have been playing with Gradle Declarative at my company but still missing this, as I want to apply plugins after some conditions, I am applying them inside
afterEvaluate
, and then I am getting an error from Kotlin Gradle plugin about
KotlinPluginLifecycle
. Is there a way to apply a plugin directly if any action is invoked? Currently I am doing something like
Copy code
foo {
   bar {
       // bar is enabled
       ... // setup bar
   }
}
Then in the plugin
Copy code
afterEvaluate {
    if (foo.bar.isEnabled.get()) { // true
        pluginManager.apply(...) // crash
    }
}
In the old setup without DCL, it was possible to apply everything when you call a block, so directly
Copy code
fun bar(action: Action<Bar>) {
    pluginManager.apply(...)
    action.execute(bar)
}
But that is not possible with DCL, AFAIK
> In the old setup without DCL, it was possible to apply everything when you call a block, so directly Even that is possible, it could lead to ordering issues that hopefully the missing piece you mentioned can fix it in the future.
p
Hey Javi, This is something we are currently investigating. We stumbled upon the same problem. We don't have an answer ready though.
j
Thank you! Is there any public place to check out those investigations?
p
Not yet
👍 1