tim
09/28/2021, 12:45 PM./gradlew tasks* What went wrong:
Failed to apply plugin class 'Build_gradle$FooPlugin'.
> Could not create plugin of type 'FooPlugin'.
   > The constructor for type Build_gradle.FooPlugin should be annotated with @Inject.tim
09/28/2021, 12:45 PMabstract class FooExtension {
    abstract val bar: Property<String>
    init {
        println("Hi from FooExt")
    }
}
class FooPlugin : Plugin<Project> {
    override fun apply(target: Project) {
        val extension = target.extensions.create<FooExtension>("foo")
        project.task("hello") {
            doLast {
                println(extension.bar.get())
            }
        }
    }
}
apply<FooPlugin>()
extensions.getByType<FooExtension>().bar.set("foo")Vampire
09/28/2021, 1:23 PM.gradle.ktsFooPluginBuild_gradletim
09/28/2021, 1:31 PMbarinit { bar.set("baz") }tim
09/28/2021, 1:32 PMVampire
09/28/2021, 1:32 PMVampire
09/28/2021, 1:32 PMbarVampire
09/28/2021, 1:32 PMVampire
09/28/2021, 1:33 PMFooPluginbuildSrcVampire
09/28/2021, 1:34 PMtim
09/28/2021, 1:34 PMtim
09/28/2021, 1:56 PMIt is very uncommon to have a plugin class within a build script, because then you could also just do the actionAgreed .. but its from the official gradle docs 🤷
tim
09/28/2021, 2:12 PMVampire
09/28/2021, 2:22 PMVampire
09/28/2021, 2:23 PMprojecttargetproject.taskprojectVampire
09/28/2021, 2:24 PMproject.tasktarget.tasktim
09/28/2021, 2:24 PMVampire
09/28/2021, 2:25 PM