You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2008/05/18 14:52:12 UTC
svn commit: r657555 -
/maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
Author: bentmann
Date: Sun May 18 05:52:12 2008
New Revision: 657555
URL: http://svn.apache.org/viewvc?rev=657555&view=rev
Log:
[MPLUGIN-115] Limit detail help output to a single goal
Modified:
maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
Modified: maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java?rev=657555&r1=657554&r2=657555&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java (original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java Sun May 18 05:52:12 2008
@@ -158,7 +158,8 @@
}
descriptor.setDescription( "Display help information on " + pluginDescriptor.getArtifactId()
- + ". Call 'mvn " + descriptor.getFullGoalName() + " -Ddetail=true' to display parameter details." );
+ + ". Call <pre> mvn " + descriptor.getFullGoalName()
+ + " -Ddetail=true -Dgoal=<goal-name></pre> to display parameter details." );
try
{
@@ -173,6 +174,15 @@
}
{
Parameter param = new Parameter();
+ param.setName( "goal" );
+ param.setType( "java.lang.String" );
+ param.setDescription( "The name of the goal for which to show help."
+ + " If unspecified, all goals will be displayed." );
+ param.setExpression( "${goal}" );
+ descriptor.addParameter( param );
+ }
+ {
+ Parameter param = new Parameter();
param.setName( "lineLength" );
param.setType( "int" );
param.setDescription( "The maximum length of a display line." );
@@ -393,9 +403,12 @@
writer.write( " append( sb, \"\", 0 );" + LS );
writer.write( LS );
- writer.write( " append( sb, \"This plugin has " + mojoDescriptors.size() + " "
+ writer.write( " if ( goal == null || goal.length() <= 0 )" + LS );
+ writer.write( " {" + LS );
+ writer.write( " append( sb, \"This plugin has " + mojoDescriptors.size() + " "
+ ( mojoDescriptors.size() > 1 ? "goals" : "goal" ) + ":\", 0 );" + LS );
- writer.write( " append( sb, \"\", 0 );" + LS );
+ writer.write( " append( sb, \"\", 0 );" + LS );
+ writer.write( " }" + LS );
writer.write( LS );
@@ -416,17 +429,21 @@
private static void writeGoal( Writer writer, MojoDescriptor descriptor )
throws IOException
{
- writer.write( " append( sb, \"" + StringUtils.escape( descriptor.getFullGoalName() ) + "\", 0 );" + LS );
- writer.write( " append( sb, \"" + toDescription( descriptor.getDescription() ) + "\", 1 );" + LS );
+ writer.write( " if ( goal == null || goal.length() <= 0 || \""
+ + StringUtils.escape( descriptor.getGoal() ) + "\".equals( goal ) )" + LS );
+ writer.write( " {" + LS );
+ writer.write( " append( sb, \"" + StringUtils.escape( descriptor.getFullGoalName() ) + "\", 0 );"
+ + LS );
+ writer.write( " append( sb, \"" + toDescription( descriptor.getDescription() ) + "\", 1 );" + LS );
+ writer.write( " append( sb, \"\", 0 );" + LS );
if ( descriptor.getParameters() != null && descriptor.getParameters().size() > 0 )
{
- writer.write( " if ( detail )" + LS );
- writer.write( " {" + LS );
+ writer.write( " if ( detail )" + LS );
+ writer.write( " {" + LS );
- writer.write( " append( sb, \"\", 0 );" + LS );
- writer.write( " append( sb, \"Available parameters:\", 1 );" + LS );
- writer.write( " append( sb, \"\", 0 );" + LS );
+ writer.write( " append( sb, \"Available parameters:\", 1 );" + LS );
+ writer.write( " append( sb, \"\", 0 );" + LS );
for ( Iterator it = descriptor.getParameters().iterator(); it.hasNext(); )
{
@@ -439,11 +456,10 @@
}
}
- writer.write( " }" + LS );
+ writer.write( " }" + LS );
}
- writer.write( LS );
- writer.write( " append( sb, \"\", 0 );" + LS );
+ writer.write( " }" + LS );
writer.write( LS );
}
@@ -460,8 +476,9 @@
+ ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) ? " (Default: "
+ StringUtils.escape( parameter.getDefaultValue() ) + ")" : "" );
- writer.write( " append( sb, \"" + parameterDefaultValue + "\", 2 );" + LS );
- writer.write( " append( sb, \"" + parameterDescription + "\", 3 );" + LS );
+ writer.write( " append( sb, \"" + parameterDefaultValue + "\", 2 );" + LS );
+ writer.write( " append( sb, \"" + parameterDescription + "\", 3 );" + LS );
+ writer.write( " append( sb, \"\", 0 );" + LS );
}
}