I’ve been creating my own gradle plugin for the last few days (partly for learning, and partly to clean up some gradle build scripts I have laying around), however I’ve run into a problem that I can’t figure out how to fix. In my plugin jar there is an interface named
me.alxandr.gradle.bintray.maven.MavenPackage, yet when I try to import it I get an error saying that it can’t be found. This is really weird, because the plugin is obviously running (I’m seeing output from it, and it’s tasks are registering).
Currently I’ve done a hack to get around this as following:
project.ext.MavenPackage = MavenPackage
This just makes
MavenPackage an available name in the buildscript, which works, but I loose any editor support for it cause it’s entirely dynamic. Is there any way I can (from my plugin) get the buildscript to import a package when it’s applied? Like how
MavenPublication is in scope without me needing to import it. If not, why can I not import classes from my plugin package?
The entire source code is available at https://github.com/Alxandr/gradle-utils. You can see an attempted here: https://github.com/Alxandr/gradle-utils/blob/master/gradle/publish.gradle#L1. The current code works as is (with the hack explained above), but I’m just looking for a better way to do this.