Ksawery Karwacki
09/09/2024, 9:51 AMmyExtension.mySubExtentions.variable.set("test")
but this throws errors:
myExtension {
mySubExtension {
variable.set("test")
}
}
I use code like this to add my base extension as property:
@Suppress("UNCHECKED_CAST")
fun <T : Any> Any.requiredExtension(name: String): T =
(this as ExtensionAware).extensions.getByName(name) as T
val Project.alpha: AlphaExtension
get() = this.requiredExtension(ALPHA_EXTENSION_NAME)
And then in another plugin:
val AlphaExtension.version: VersionExtension
get() = this.requiredExtension(ALPHA_VERSION_EXTENSION_NAME)
It seems like it's missing accessor in format:
fun myExtension(configure: Action<MyExtension>): Unit {do something...}
because at least first level is accessible when I add:
fun Project.alpha(configure: Action<AlphaExtension>) {
configure.execute(alpha)
}
Is this expected behavior? Am I missing something or did something wrong? It works properly when I import my plugin in external project so it seems that normally Gradle adds those Accessors automatically.Vampire
09/09/2024, 10:14 AMVampire
09/09/2024, 10:14 AMVampire
09/09/2024, 10:15 AMplugins { ... } block