Option 1:
If you are using gradle 3.1 or later, you can use the composite build feature.
Build your standalone module like this: gradle build --include-build /path/to/plugin-root
Assuming you run this command from the root of a standalone gradle project that applies the plugin, this would first build the plugin, then build your standalone project and apply the just built plugin to it.
Option 2:
If you use an older gradle version (which does not support composite builds), you can apply the maven plugin to your plugin project. This defines the install
task, which you can now call by running gradle install
in the root of your plugin project.
This task builds your plugin and puts the resulting jar
in a local cache directory (on Linux the default path is ~/.m2
).
Notice that after every change you make in the plugin code, you have to run gradle install
again.
Now, for your standalone project to use the local plugin jar
, you need to edit the build script and put mavenLocal()
under buildscript.repositories
. Make sure that mavenLocal()
is above anything else in the repositories
block.
Example of the buildscript block of your standalone project:
buildscript {
repositories {
mavenLocal()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.mycompany.plugins:my-awsome-plugin:1.0.0"
}
}