The Maven Plugin Tool for Java is the Java impl of maven-plugin-tools-api to extract descriptors for plugins written in Java annotated with Mojo Javadoc Tags.
import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Settings; /** * Mojo Description: goal is the only required annotation. * * @goal <goalName> * @aggregator * @configurator <roleHint> * @execute phase="<phaseName>" lifecycle="<lifecycleId>" goal="<goalName>" * @executionStrategy <once-per-session|always> * @inheritByDefault <true|false> * @instantiationStrategy <per-lookup|singleton|keep-alive|poolable> * @phase <phaseName> * @requiresDependencyResolution <compile|runtime|compile+runtime|test> * @requiresDependencyCollection <compile|runtime|compile+runtime|test> (since Maven 3.0) * @requiresDirectInvocation <false|true> * @requiresOnline <false|true> * @requiresProject <true|false> * @requiresReports <false|true> (unsupported since Maven 3.0) * @threadSafe (since Maven 3.0) * @since <since-text> * @deprecated <deprecated-text> */ public class MyMojo extends AbstractMojo { /** * @parameter alias="myAlias" implementation="" property="aProperty" default-value="${anExpression}" * @readonly * @required * @since <since-text> * @deprecated <deprecated-text> */ private String parameter; /** * @component role="..." roleHint="..." */ private Component component; /** * @component */ private MavenSession session; /** * @component */ private MavenProject project; /** * @component */ private MojoExecution mojo; /** * @component */ private PluginDescriptor plugin; /** * @component */ private Settings settings; public void execute() { ... } }
Notice: before 3.0, property was replaced by expression, with $ required (expression="$aProperty"), but starting with 3.0, you can omit it (expression="aProperty"), or preferably use property="aProperty".