Maven Projects

ASF

Using Plugin Tools Java5 Annotations

Since version 3.0, you can use Java5 annotations to generate the plugin descriptor file.

NOTE With annotations, your Mojo super class does not any more require to be in the same project. Provided that the super class also uses annotations, it can now come from reactor projects or external dependencies. As javadoc doclet are still useful for @since, @deprecated and comments, the sources are still scanned. So if you use an external dependency, you must still provide an artifact with sources (sources classifier) to provide documentation (the tooling will skip error if this artifact sources is missing).

Annotations

Information for plugin descriptor generation is specified using 4 annotations:

2 class-level annotations:

@Mojo: This annotation will mark your class as a Mojo,

@Execute: Used if your Mojo needs to fork a lifecycle,

2 field-level annotations:

@Parameter: Used to configure your Mojo parameters,

@Component: Used to configure injection of Plexus components or Maven context components.

Notice: this configuration will not work with Maven 2, which does not support execution phase overriding. If you absolutely need to build with Maven 2, you should use skipErrorNoDescriptorsFound parameter to avoid failure on default execution phase and add another execution: