Introduction
This is a Maven2 extension of maven-plugin-plugin that allows writing Annotated Plug-in Mojos
using JDK 1.5+ annotations instead of doclet comments.
Prerequisites
Settingsdownload zip repositoryUse the download link to get from sourceforge the zip of a maven2 format repository containing Maven Anno Mojo artifacts.If you are using Artifactory, the Web UI page "import/export" emables to import this zip directly into Artifactory. jfrog repositoryYou can also configure a maven repository with the following URL: http://www.jfrog.org/artifactory/plugins-releasesto retrieve the latest version of maven anno mojo. POM configuration<project> ... <dependencies> ... <dependency> <groupId>org.jfrog.maven.annomojo</groupId> <artifactId>maven-plugin-anno</artifactId> <version>1.3.1</version> </dependency> ... </dependencies> <build> <plugins> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-plugin-plugin</artifactId> <version>2.3</version> <dependencies> <dependency> <groupId>org.jfrog.maven.annomojo</groupId> <artifactId>maven-plugin-tools-anno</artifactId> <version>1.3.1</version> <scope>runtime</scope> </dependency> </dependencies> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> ... </plugins> </build> </project> Using Mojo AnnotationsNOTEThis 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).Class and Field AnnotationsThe Anno Mojo API project reports has the javadoc that can help.Simple Example
/** * My mojo description */ @MojoGoal("doIt") @MojoPhase("package") @MojoExecute(phase = "package") public class MyMojo { @MojoParameter 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.
public interface MvnAnnoIfc { @MojoComponent(description = "project-helper instance, used to make addition of resources simpler.") MavenProjectHelper getProjectHelper(); } Jade PluginsA good start for Maven Anno Mojo, is to use Jade Plugins common jars. Jade Plugins has also many standard maven plugins converted to Java5 with Generics and Annotations. |
|||