Child pages
  • Maven Anno Mojo
Skip to end of metadata
Go to start of metadata


This is a Maven 2 and 3 extension of maven-plugin-plugin that allows writing Annotated Plug-in Mojos using JDK 1.5+ annotations instead of doclet comments.

This has a couple of substantial benefits over using JavaDoc-style annotations:

  • You will get compile-time checks for your plugin metadata.
  • You can use annotations on interface/class getter methods instead of field annotations, which allows for greater flexibility in your plugin object model - injection inheritance being the most important one.
  • Since JDK 1.5 annotations are supported in most IDEs, you will benefit from code-completion and syntactic checks.



  • JDK 5.0 or later
  • Maven 2.2.0 or later, Maven 3.0-beta-1 or later
  • maven-plugin-plugin 2.6 or later


To use the plugin add Artifactory plugins repository and the plugin configuration to your pom.xml.



Use -Pjfrog-plugins on the first execution to download the plugin.

Using Mojo Annotations


This plugin relies on JDK 1.5 and uses the Annotation Processing Tool (APT). It is required to run Maven with JDK 1.5 or later (set your JAVA_HOME to point to the JDK not the JRE).

Simple example

 * My mojo description
@MojoExecute(phase = "package")
public class MyMojo {

    private List<Artifact> artifacts;

    @MojoParameter(expression = "${project}", required = true, readonly = true,
            description = "The Maven Project")
    private MavenProject project;

     * The local repository
    @MojoParameter(expression = "${localRepository}")
    private ArtifactRepository localRepository;


Element description is taken either from the element's JavaDoc comment or from a "description" attribute on appropriate annotations.

Getter Methods Annotations

You can also use field annotations on getter methods, either in interfaces or regular classes.

For example:

public interface MvnAnnoIfc {
    @MojoComponent(description =
        "project-helper instance, used to make addition of resources simpler.")
    MavenProjectHelper getProjectHelper();