Sergey Chelombitko
08/05/2024, 3:28 PMBuildService from the code consuming a plugin?
I cannot pass a listener via service parameters, because they have to be Serializable, but the listener is not.
So far, I haven't found a better way that passing the listener via a singleton object:
// Inside the plugin:
object MyListenerHolder {
var listener: MyListener? = null
}
abstract class MyService : BuildService {
val logic by lazy {
Logic(MyListenerHolder.listener)
}
}
// Consumer code:
plugins.withId("com.myplugin") {
MyListenerHolder.listenter = MyListenerImpl()
}