Hi @eskatos.
I’m writing Gradle plugin in Kotlin and I’m looking for a way how to extend some existing object. For example
fun Project.example1() {
println("example")
}
or Android specific one
fun ProductFlavor.setSignKey(remoteSignKeyName: RemoteSignKeyName) {
this.extra["signKeyName"] = remoteSignKeyName
}
But I didn’t found a way how to do that. Your response is the most promising thing that I found so far.
There is possible to use project.extensions.create which generates accessors in kt file event without using gradle.kts. There is really no way how to do something similar for any other class, directly from .kt files?
But I tried also you suggested solution via .gradle.kts
and it also doesn’t work for me.
I simply put KotlinExtension.gradle.kts
file to my plugin scr/main/kotlin folder and inside of project I can use
plugins {
...
id("KotlinExtension")
This par works. But if I put something like
fun Project.example1() {
println("example")
}
to this .gradle.kts
file i still can call example1()
method on project
object