I am developing a plugin with an extension. I pass a project into this extension as a parameter, and use it to configure certain task when the extension’s methods are called.
Plugin code:
class MyPlugin : Plugin<Project> {
override fun apply(target: Project): Unit = target.run {
extensions.create<MyPluginExtension>("exten", project)
tasks.register("blah")
}
}
Extension code:
open class MyPluginExtension @Inject constructor(val project: Project) {
fun configureTasks() {
project.tasks.named("blah") { ... }
}
}
Is this OK? Don’t I cause any memory leaks or something else stupid?