Collection of many plugins can also be called as “Maven” in simple. As Maven consists of a core engine which provides basic project-processing capabilities and build-process management used to execute the actual build tasks.

What is a Maven Plugin?

“Maven” is really just a core framework for a collection of Maven Plugins. In other words, plugins are where much of the real action is performed, plugins are used to: create jar files, create war files, compile code, unit test code, create project documentation, and on and on. Almost any action that you can think of performing on a project is implemented as a Maven plugin.

Plugins are the central feature of Maven that allow for the reuse of common build logic across multiple projects. They do this by executing an “action” (i.e. creating a WAR file or compiling unit tests) in the context of a project’s description – the Project Object Model (POM). Plugin behavior can be customized through a set of unique parameters which are exposed by a description of each plugin goal (or Mojo).

One of the simplest plugins in Maven is the Clean Plugin. The Maven Clean plugin (maven-clean-plugin) is responsible for removing the target directory of a Maven project. When you run “mvn clean”, Maven executes the “clean” goal as defined in the Clean plug-in, and the target directory is removed. The Clean plugin defines a parameter which can be used to customize plugin behavior, this parameter is called outputDirectory and it defaults to ${}.

What is a ‘Mojo’ ?

A Mojo is really just a goal in Maven, and plug-ins consist of any number of goals (Mojos). Mojos can be defined as annotated Java classes or Beanshell script. A Mojo specifies metadata about a goal: a goal name, which phase of the lifecycle it fits into, and the parameters it is expecting.

MOJO is a play on POJO (Plain-old-Java-object), substituting “Maven” for “Plain”.

Each Mojo is an executable goal in Maven, and a plugin is a distribution of one or more related mojos.

What is the Build Lifecycle? (Overview)

Please refer this article for getting more information about Build Lifecycle.

The build lifecycle is a series of common stages through which all project builds naturally progress. Plugin goals are bound to specific stages in the lifecycle.

How to use Maven Plugins?

As you will see in the later sections, plugins can contain information that indicates which lifecycle phase to bind a goal to. Note that adding the plugin on its own is not enough information – you must also specify the goals you want to run as part of your build.

Whenever you want to customise the build for a Maven project, this is done by adding or reconfiguring plugins.

For this example, we will configure the Java compiler to allow JDK 5.0 sources. This is as simple as adding this to your POM:


You’ll notice that all plugins in Maven look much like a dependency – and in some ways they are. This plugin will be automatically downloaded and used – including a specific version if you request it (the default is to use the latest available).

The configuration element applies the given parameters to every goal from the compiler plugin. In the above case, the compiler plugin is already used as part of the build process and this just changes the configuration. It is also possible to add new goals to the process, and configure specific goals.

To find out what configuration is available for a plugin, you can see the Plugins List and navigate to the plugin and goal you are using.


Hence we saw what is Maven plugin, Mojo and how to use plugin. In our next article, we can see how to configure plugins in Maven.