Jun 05, 2007
Currently only available in mvn 2.1.x
Since Java 5 annotations are not built in to Maven core (yet) they require a bit of wrangling to use. Your plugin's pom must contain the following:
Firstly, you must add the annotation dependency to your plugin's dependency list.
This allows your project mojos access to the 4 annotation classes:
The first two are Type (class-level) annotation, the last two are Field annotations.
There is also an enum org.apache.maven.tools.plugin.lifecycle.Phase - which contains values corresponding to the default phases (VALIDATE, COMPILE, TEST, DEPLOY...), clean (PRE_CLEAN, CLEAN...) and site (SITE, SITE_DEPLOY...). The Goal "defaultPhase" field accepts an enum Phase value only as well as the Execute "phase" field accepts an enum Phase ("customPhase" field can accept a string).
Currently you must add the "maven-plugin-tools-java5" artifact to the maven-plugin-plugin dependency, since it is not a dependency by default. Moreover, you must add "post-compile-descriptor" goal execution (binds to "process-classes"). The compiler must also be set to jdk 1.5 or greater, or your mojo compilation will fail.
Note: The existing maven-plugin-plugin will fail if no mojos are found during the "descriptor" goal execution (which is run as part of a "maven-project" packaging type. Since you cannot skip this goal - your plugin either must contain a mojo using plain-old-fashioned javadoc annotations - or package your project as a "jar" and manually add the other plugin-plugin goal executions - or add a javadoc to one goal with a /** @goal "name" */ class comment. None are good long-term solutions, so this must be fixed.
Powered by a free Atlassian Confluence Open Source Project License granted to Codehaus. Evaluate Confluence today.