[MPLUGIN-231] Switch to plugin annotations for the generated help-mojo if the Maven Plugin depends on maven-plugin-annotations
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1405371 13f79535-47bb-0310-9956-ffa450edef68master
parent
27581ab1ee
commit
0435027899
|
|
@ -37,7 +37,7 @@ import java.io.File;
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
* @since 2.4
|
* @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
|
public class HelpGeneratorMojo
|
||||||
extends AbstractGeneratorMojo
|
extends AbstractGeneratorMojo
|
||||||
{
|
{
|
||||||
|
|
@ -75,7 +75,7 @@ public class HelpGeneratorMojo
|
||||||
*/
|
*/
|
||||||
protected Generator createGenerator()
|
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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,8 @@ public class PluginHelpGenerator
|
||||||
|
|
||||||
private String helpPackageName;
|
private String helpPackageName;
|
||||||
|
|
||||||
|
private boolean useAnnotations;
|
||||||
|
|
||||||
private VelocityComponent velocityComponent;
|
private VelocityComponent velocityComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -158,6 +160,12 @@ public class PluginHelpGenerator
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PluginHelpGenerator setUseAnnotations( boolean useAnnotations )
|
||||||
|
{
|
||||||
|
this.useAnnotations = useAnnotations;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public VelocityComponent getVelocityComponent()
|
public VelocityComponent getVelocityComponent()
|
||||||
{
|
{
|
||||||
return velocityComponent;
|
return velocityComponent;
|
||||||
|
|
@ -188,6 +196,7 @@ public class PluginHelpGenerator
|
||||||
properties.put( "pluginHelpPath", pluginHelpPath );
|
properties.put( "pluginHelpPath", pluginHelpPath );
|
||||||
properties.put( "artifactId", pluginDescriptor.getArtifactId() );
|
properties.put( "artifactId", pluginDescriptor.getArtifactId() );
|
||||||
properties.put( "goalPrefix", pluginDescriptor.getGoalPrefix() );
|
properties.put( "goalPrefix", pluginDescriptor.getGoalPrefix() );
|
||||||
|
properties.put( "useAnnotations", useAnnotations );
|
||||||
|
|
||||||
StringWriter stringWriter = new StringWriter();
|
StringWriter stringWriter = new StringWriter();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,33 +34,49 @@ public class HelpMojo
|
||||||
/**
|
/**
|
||||||
* If <code>true</code>, display all settable properties for each goal.
|
* If <code>true</code>, display all settable properties for each goal.
|
||||||
*
|
*
|
||||||
|
#if ( !$useAnnotations )
|
||||||
* @parameter property="detail" default-value="false"
|
* @parameter property="detail" default-value="false"
|
||||||
|
#end
|
||||||
*/
|
*/
|
||||||
//@Parameter( property = "detail", defaultValue = "false" )
|
#if ( $useAnnotations )
|
||||||
|
@Parameter( property = "detail", defaultValue = "false" )
|
||||||
|
#end
|
||||||
private boolean detail;
|
private boolean detail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the goal for which to show help. If unspecified, all goals will be displayed.
|
* The name of the goal for which to show help. If unspecified, all goals will be displayed.
|
||||||
*
|
*
|
||||||
|
#if ( !$useAnnotations )
|
||||||
* @parameter property="goal"
|
* @parameter property="goal"
|
||||||
|
#end
|
||||||
*/
|
*/
|
||||||
//@Parameter( property = "goal" )
|
#if ( $useAnnotations )
|
||||||
|
@Parameter( property = "goal" )
|
||||||
|
#end
|
||||||
private java.lang.String goal;
|
private java.lang.String goal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum length of a display line, should be positive.
|
* The maximum length of a display line, should be positive.
|
||||||
*
|
*
|
||||||
|
#if ( !$useAnnotations )
|
||||||
* @parameter property="lineLength" default-value="80"
|
* @parameter property="lineLength" default-value="80"
|
||||||
|
#end
|
||||||
*/
|
*/
|
||||||
//@Parameter( property = "lineLength", defaultValue = "80" )
|
#if ( $useAnnotations )
|
||||||
|
@Parameter( property = "lineLength", defaultValue = "80" )
|
||||||
|
#end
|
||||||
private int lineLength;
|
private int lineLength;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of spaces per indentation level, should be positive.
|
* The number of spaces per indentation level, should be positive.
|
||||||
*
|
*
|
||||||
|
#if ( !$useAnnotations )
|
||||||
* @parameter property="indentSize" default-value="2"
|
* @parameter property="indentSize" default-value="2"
|
||||||
|
#end
|
||||||
*/
|
*/
|
||||||
//@Parameter( property = "indentSize", defaultValue = "2" )
|
#if ( $useAnnotations )
|
||||||
|
@Parameter( property = "indentSize", defaultValue = "2" )
|
||||||
|
#end
|
||||||
private int indentSize;
|
private int indentSize;
|
||||||
|
|
||||||
// groupId/artifactId/plugin-help.xml
|
// groupId/artifactId/plugin-help.xml
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue