Norbi
06/16/2023, 8:10 AMSam
06/16/2023, 8:11 AMext
property and then have the script plugin read it in an afterEvaluate
block. It’s not nice, though. If dynamic behaviour is needed, I would make a “real” plugin.Javier
06/16/2023, 8:47 AMVampire
06/16/2023, 8:48 AMVampire
06/16/2023, 8:48 AMVampire
06/16/2023, 8:48 AMext
or extra
is is more a dirty work-around and you should feel dirty. 😄Vampire
06/16/2023, 8:49 AMafterEvaluate
is practically always evil and should be avoided as hell. It usually just introduces timing problems, ordering problems, and race conditions.Sam
06/16/2023, 8:49 AMSam
06/16/2023, 8:50 AMVampire
06/16/2023, 8:50 AMNorbi
06/16/2023, 9:39 AMVampire
06/16/2023, 9:58 AMextensions.create...
.Vampire
06/16/2023, 9:58 AMSam
06/16/2023, 10:27 AMinterface MyExtension {
val myVersion: Property<String>
}
val myExtension = extensions.create<MyExtension>("myExtension")
dependencies {
implementation(myExtension.myVersion.orElse("3.2.1").map { "com.example:something:$it" })
}
and in `build.gradle.kts`:
plugins {
my.plugin
}
myExtension {
myVersion.set("1.2.3")
}
It works, because the dependency provider isn’t evaluated until after the extension has been configured. But it feels a little fragile, and I’m wondering if there’s a better way for the plugin to “listen” for changes in the property 🤔.Vampire
06/16/2023, 10:37 AMSam
06/16/2023, 10:38 AMmap
a “correct” approach?Javier
06/16/2023, 10:39 AMVampire
06/16/2023, 10:39 AMVampire
06/16/2023, 10:40 AMIstill miss a phase which allows applying plugins conditionally and still getting accessors.And you probably will forever. Generated accessor means, what you want to access is guaranteed to be there. That's the point of the type-safe generated accessors.
Javier
06/16/2023, 10:40 AMJavier
06/16/2023, 12:28 PMJavier
06/16/2023, 12:29 PMJavier
06/16/2023, 12:32 PMconvention {
plugins {
alias(libs.plugins.hubdle)
}
hubdle {
kotlin {
multiplatform {
features {
coroutines()
serialization()
sqldelight()
}
}
}
}
}
plugins {
// likely empty always
}
// generated accessors for KMP, Serialization and Sqldelight extensions
Javier
06/16/2023, 12:34 PMVampire
06/16/2023, 1:39 PMplugins { ... }
block that is extracted and applied to a dummy project is intentionally very restricted on what you can do there, that this works properly.
Such a special block you describe could practically do any turing-complete logic that might then fail when extracted and run separately and so on.
I still don't think anything like that will be added, but feel free to open a feature request if you think it is different to for example https://github.com/gradle/gradle/issues/16107 which was refused already.Javier
06/16/2023, 1:54 PM