Groovy extension methods in gradle plugin

I have a Gradle plugin with some Groovy extension methods.

The plugin has a org.codehaus.groovy.runtime.ExtensionModule file in the META-INF/groovy directory.

However, extension methods don’t get loaded in Groovy and so I can’t use them in the build.gradle file.

If I use the use(...) { ... } construction, I can use them in the build.gradle file.

Is there any way to get the extension methods in a Gradle plugin to be usable in a build.gradle file without having to use the use(...) { ... } construction, but instead use the module descriptor [1] ?



I cannot answer that question for you, but in terms of DSL usability I would like to drop an observation.

I think that Groovy extensions in a Gradle context are not a good idea, primarily because they cannot be used in a Kotlin DSL. If this is internal to your company, then maybe that is not a problem, but for an open-source plugin that is definitely a consideration

I already have Kotlin extensions but those aren’t usable from Groovy :). I wanted to make the plugin as usable from Groovy as it is from Kotlin since Gradle supports both languages.

Unfortunately Groovy extensions currently don’t work in Gradle Groovy scripts.