diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java index 87a179a..e31274c 100644 --- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java +++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/HelpGeneratorMojo.java @@ -32,12 +32,12 @@ import java.io.File; /** * Generates a HelpMojo class. - * + * * @author Vincent Siveton * @version $Id$ * @since 2.4 */ -@Mojo( name = "helpmojo", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true ) +@Mojo( name = "helpmojo", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true /*, requiresDependencyResolution = ResolutionScope.COMPILE */ ) public class HelpGeneratorMojo extends AbstractGeneratorMojo { @@ -50,7 +50,7 @@ public class HelpGeneratorMojo /** * The name of the package for the generated HelpMojo. By default, the package will be calculated based * on the packages of the other plugin goals. - * + * * @since 2.6 */ @Parameter @@ -75,7 +75,7 @@ public class HelpGeneratorMojo */ protected Generator createGenerator() { - return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setVelocityComponent( this.velocity ); + return new PluginHelpGenerator().setHelpPackageName( helpPackageName ).setUseAnnotations( project.getArtifactMap().containsKey( "org.apache.maven.plugin-tools:maven-plugin-annotations" ) ).setVelocityComponent( this.velocity ); } /** diff --git a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java index cf8552a..b45c113 100644 --- a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java +++ b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java @@ -88,6 +88,8 @@ public class PluginHelpGenerator private String helpPackageName; + private boolean useAnnotations; + private VelocityComponent velocityComponent; /** @@ -157,6 +159,12 @@ public class PluginHelpGenerator this.helpPackageName = helpPackageName; return this; } + + public PluginHelpGenerator setUseAnnotations( boolean useAnnotations ) + { + this.useAnnotations = useAnnotations; + return this; + } public VelocityComponent getVelocityComponent() { @@ -188,6 +196,7 @@ public class PluginHelpGenerator properties.put( "pluginHelpPath", pluginHelpPath ); properties.put( "artifactId", pluginDescriptor.getArtifactId() ); properties.put( "goalPrefix", pluginDescriptor.getGoalPrefix() ); + properties.put( "useAnnotations", useAnnotations ); StringWriter stringWriter = new StringWriter(); diff --git a/maven-plugin-tools-generators/src/main/resources/help-class-source.vm b/maven-plugin-tools-generators/src/main/resources/help-class-source.vm index 7540dc6..407f9a7 100644 --- a/maven-plugin-tools-generators/src/main/resources/help-class-source.vm +++ b/maven-plugin-tools-generators/src/main/resources/help-class-source.vm @@ -34,33 +34,49 @@ public class HelpMojo /** * If true, display all settable properties for each goal. * +#if ( !$useAnnotations ) * @parameter property="detail" default-value="false" +#end */ - //@Parameter( property = "detail", defaultValue = "false" ) +#if ( $useAnnotations ) + @Parameter( property = "detail", defaultValue = "false" ) +#end private boolean detail; /** * The name of the goal for which to show help. If unspecified, all goals will be displayed. * +#if ( !$useAnnotations ) * @parameter property="goal" +#end */ - //@Parameter( property = "goal" ) +#if ( $useAnnotations ) + @Parameter( property = "goal" ) +#end private java.lang.String goal; /** * The maximum length of a display line, should be positive. * +#if ( !$useAnnotations ) * @parameter property="lineLength" default-value="80" +#end */ - //@Parameter( property = "lineLength", defaultValue = "80" ) +#if ( $useAnnotations ) + @Parameter( property = "lineLength", defaultValue = "80" ) +#end private int lineLength; /** * The number of spaces per indentation level, should be positive. * +#if ( !$useAnnotations ) * @parameter property="indentSize" default-value="2" +#end */ - //@Parameter( property = "indentSize", defaultValue = "2" ) +#if ( $useAnnotations ) + @Parameter( property = "indentSize", defaultValue = "2" ) +#end private int indentSize; // groupId/artifactId/plugin-help.xml