This message was deleted.
# plugin-development
s
This message was deleted.
j
I cannot use
afterEvaluate
e
I think you are facing an order problem. Consider this
Copy code
// plugin.kt

    class MyPlugin {
(2)   fun apply() { ... }
    }
and then…
Copy code
// 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
Copy code
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.
j
exactly, that is the problem
Copy code
plugins {
    id("some.plugin")
}

somePlugin {
    someProp.set("v")
}

println(project.version) // this is happening before reading the the someProp
I did a workaround by using a Gradle project property