This plugin aims to fill the tiny gap for people who need to create an Apache Maven plugin from a Gradle build. To do this the plugin wraps around the Maven Plugin Tools API and feeds it with the right inputs from the Gradle build.
Compatible with Gradle 7.5 or later.
Features
-
Automatic generation of a maven plugin descriptor containing all mojos in the selected source set (by default the plugin looks for mojo implementations in the main source set)
-
Support for annotation and JavaDoc tag based mojo implementations
-
Optional generation of a help mojo implementation
Usage
Once applied, the plugin adds a MavenPluginDevelopmentExtension
with name mavenPlugin
to the project.
All metadata for the plugin, e.g. groupId
, artifactId
, description
is extracted from the corresponding project properties.
plugins {
id 'org.gradlex.maven-plugin-development' version '1.0.1'
}
plugins {
id("org.gradlex.maven-plugin-development") version "1.0.1"
}
HelpMojo generation
It’s possible to generate a help mojo that help users to discover the functionality of your Maven plugin. By default generation of a help mojo is disabled. To enable it specify the package the HelpMojo should be generated in:
mavenPlugin {
helpMojoPackage = 'org.example.help'
}
mavenPlugin {
helpMojoPackage.set("org.example.help")
}
Controlling plugin dependencies
By default, all dependencies from the runtime classpath will be added to the dependencies block of the generated plugin descriptor.
This can be changed by configuring the dependencies
property on the mavenPlugin
extension.
In the following examples only org.apache.commons:commons-lang3:3.9
will be added as a dependency to the plugin descriptor:
configurations {
deps
}
dependencies {
deps "org.apache.commons:commons-lang3:3.17.0"
implementation "com.google.guava:guava:33.4.0-jre"
}
mavenPlugin {
dependencies = configurations.deps
}
val deps by configurations.creating
dependencies {
deps("org.apache.commons:commons-lang3:3.17.0")
implementation("com.google.guava:guava:33.4.0-jre")
}
mavenPlugin {
dependencies.set(deps)
}