O'Reilly logo

Maven Build Customization by Giacomo Veneri, Riccardo Giomi, Umberto Antonio Cicero, Roberto Baldi, Lorenzo Anardu

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing Mojo

What is a Mojo? A simple definition for Mojo is that Mojo is a Maven goal. This is not far from reality.

In order to be more accurate, we can say that a Mojo is a Maven plain Old Java Object. Each Mojo is an executable goal in Maven, and a plugin is a distribution of one or more related Mojos.

In practice, to create a Mojo, we must create a class extending the abstract class, as follows:

org.apache.maven.plugin.AbstractMojo

Such a class provides a utility method for common operations. Furthermore, it provides the abstract method, public void execute() throws MojoExecutionException, to perform all the dirty work when the plugin is executed.

In order to associate our Mojo to a goal for our plugin, we have to use an annotation in Java ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required