How can I get a hold of the `initscript` ScriptHandler from a plugin

(Dimitar Dimitrov) #1

I am creating an internal distribution for Gradle, and to make things more testable/faster I am trying to move as much as possible to bundled plugins.

I found that while the documentation states that Gradle is the delegate for init scripts, it doesn’t seem to expose the initscript script handler in the same way as Project exposes buildscript.

Also, it seems that Gradle does not allow for registering of extensions, which forces me to use the actual plugin class as an API for the user-configurable parts of the init script.

Any tips?

(Dimitar Dimitrov) #2

Answering my own question, the initscript and buildscript are quite special in the way they are handled, and in my case, I’m rethinking the approach as to not need access to initscript from a plugin (becomes chicken and egg problem).

For more details, see the DefaultInitScriptProcessor, DefaultScriptPluginFactory, and InitScriptTarget. Do pay attention to the initial vs second compile-pass Groovy transformations (I wonder how is it handled in Kotlin?)

Overall, in few hours learned more about Gradle than I really wanted to know. I hope I won’t be forced to deal with it anytime soon.