

This is the group ID for the plugin, and should match the common prefix to the packages used by the mojosĪ dependency must be declared to the Maven Plugin Tools API to resolve " AbstractMojo" and related classes To do this properly, the project's descriptor needs to have a number of settings set properly: groupId Once the mojos have been written for the plugin, it is time to build the plugin. Please have a look at the section Retrieving the Mojo Logger for a hint on its proper usage.Īll Mojo annotations are described by the Mojo API Specification. This logger is the accepted means to display information to the user. The getLog method (defined in AbstractMojo) returns a log4j-like logger object which allows plugins to create messages at levels of "debug", "info", "warn", and "error".Throwing this exception causes a "BUILD FAILURE" message to be displayed. .MojoFailureException if an expected problem (such as a compilation failure) occurs.Throwing this exception causes a "BUILD ERROR" message to be displayed. .MojoExecutionException if an unexpected problem occurs.The execute method can throw two exceptions:.The annotation " is required and control how and when the mojo is executed.The class .AbstractMojo provides most of the infrastructure required to implement a mojo except for the execute method.

Public void execute() throws MojoExecutionException Public class GreetingMojo extends AbstractMojo After the listing is a description of the various parts of the source. This is about as simple as a mojo can be. Listed below is a simple mojo class which has no parameters. Any class with this annotation are included in the plugin configuration file. When processing the source tree to find mojos, plugin-tools looks for classes with either Java 5 annotation or " goal" javadoc annotation.
#Install java plugin map writer code#
There is no requirement for multiple classes like EJBs, although a plugin which contains a number of similar mojos is likely to use an abstract superclass for the mojos to consolidate code common to all mojos.

Your First MojoĪt its simplest, a Java mojo consists simply of a single class representing one plugin's goal. Along the way, we will cover the basics of setting up a project to create a plugin, the minimal contents of a Java mojo which will define goal code, and a couple ways to execute the mojo. In this section we will build a simple plugin with one goal which takes no parameters and simply displays a message on the screen when run. Using this naming pattern is an infringement of the Apache Maven Trademark. You will typically name your plugin -maven-plugin.Ĭalling it maven-plugin (note "Maven" is at the beginning of the plugin name) is strongly discouraged since it's a reserved naming pattern for official Apache Maven plugins maintained by the Apache Maven team with groupId. Important Notice: Plugin Naming Convention and Apache Maven Trademark This guide is intended to assist users in developing Java plugins for Maven.
