------ Using Plugin Tools Java5 Annotations ------ Olivier Lamy ------ 2012-05-14 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ NOTE: For help with the syntax of this file, see: ~~ http://maven.apache.org/doxia/references/apt-format.html Using Plugin Tools Java5 Annotations Since version 3.0, you can use {{{#Annotations}Java5 annotations}} to generate the plugin descriptor file. <> With annotations, it's not any more mandatory to have your Mojos super classes in the same project. Super classes 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 (<<>> classifier) to provide documentation (the tooling will skip error if this artifact sources is missing). * Pom configuration +-----+ ... org.apache.maven.plugin-tools maven-plugin-annotations ${project.version} org.codehaus.plexus plexus-utils 3.0.1 ... org.apache.maven.plugins maven-plugin-plugin ${project.version} true mojo-descriptor descriptor help-goal helpmojo ... ... +-----+ * 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. See {{{/plugin-tools/maven-plugin-annotations/apidocs/org/apache/maven/plugins/annotations/Mojo.html}javadoc}} for more information. * <<<@Execute>>>: Used if your Mojo need to fork a lifecycle. See {{{/plugin-tools/maven-plugin-annotations/apidocs/org/apache/maven/plugins/annotations/Execute.html}javadoc}} for more information. [] * 2 field-level annotations: * <<<@Parameter>>>: Used to configure your Mojo parameters. See {{{/plugin-tools/maven-plugin-annotations/apidocs/org/apache/maven/plugins/annotations/Parameter.html}javadoc}} for more information. * <<<@Component>>>: Used to configure injection of Plexus components or Maven context components. See {{{/plugin-tools/maven-plugin-annotations/apidocs/org/apache/maven/plugins/annotations/Component.html}javadoc}} for more information. [] [] Plugin Tools Java 5 Annotations ({{{../../maven-plugin-tools-annotations/index.html}see full example}}) are named after Plugin Tools Javadoc Tags ({{{../../maven-plugin-tools-java/index.html}see full example}}), with following little differences: *-------------------------------+---------------+ || Plugin Tools Javadoc Tags || Plugin Tools Java 5 Annotation || *-------------------------------+---------------+ | <<<@goal "goal-name">>> | <<<@Mojo( name = "goal-name" )>>> *-------------------------------+---------------+ | <<<@phase "\">>> | <<<@Mojo( defaultPhase = "\" )>>> *-------------------------------+---------------+