I’m trying to create a custom gradle init script: ...
# gradle
i
I’m trying to create a custom gradle init script:
Copy code
package art.me.init
Copy code
import java.net.URI

apply<InitPlugin>()

class InitPlugin : Plugin<Gradle> {
   override fun apply(gradle: Gradle) {
   ...
   }
}
But when running the script it get:
Copy code
* What went wrong:
Failed to apply plugin class 'art.me.init.Me_init_gradle$InitPlugin'.
> Could not create plugin of type 'InitPlugin'.
   > Class Me_init_gradle.InitPlugin is a non-static inner class.
Though according to https://docs.gradle.org/current/userguide/init_scripts.html#sec:init_script_plugins it should work. Can anyone help?
v
I just tried with
Copy code
apply<Foo>()

class Foo : Plugin<Gradle> {
    override fun apply(gradle: Gradle) {
        println("FOO")
    }
}
in an init script and it worked just fine. What Gradle version do you use?
Can you knit an MCVE?
i
i’m on V 8.1.1
Sure, i’ll do it later today
e
make sure you don't have any accidental
project
references
v
Probably not
project
as it is an init plugin. But probably something else from the init script context that then makes it a non-static class, yes. 🙂
202 Views