Slackbot
08/27/2022, 1:12 PMJavi
08/27/2022, 1:13 PMafterEvaluate
efemoney
08/29/2022, 6:27 AM// plugin.kt
class MyPlugin {
(2) fun apply() { ... }
}
and then…
// build.gradle.kts
plugin {
(1) id("my-plugin")
}
myPlugin {
(3) myProperty.set(...)
}
(4) ... // other code
tasks.register("aTask") {
(5) ... // lazy task configuration
}
The order of execution is 1,2,3,4 & 5. All run in the configuration phase except 5 which runs in execution phase (if set up properly).
However, “configuration phase” to your plugin is execution number (2). Theres no way code that runs in 2 will “know about” what happens in 3 & 4 later.
Now you can set up your value source using lazy properties so that in (2) you have
val myPluginExt = ...
val myValueSource = providers.value(MyValueSource::class) {
myValueProperty.set(muPluginExt.myProperty)
}
but if you try to resolve this value source in this same step 2, then it will be the default/empty since 3 & 4 have not run yet.
So your options are to delay the resolution of the value source to the execution phase (within some task) or use afterEvaluate.Javi
08/30/2022, 4:11 PMplugins {
id("some.plugin")
}
somePlugin {
someProp.set("v")
}
println(project.version) // this is happening before reading the the someProp
Javi
08/30/2022, 4:12 PM