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/09 16:56:53 UTC
svn commit: r654838 -
/maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
Author: bentmann
Date: Fri May 9 07:56:53 2008
New Revision: 654838
URL: http://svn.apache.org/viewvc?rev=654838&view=rev
Log:
o Refactored to reduce method size
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=654838&r1=654837&r2=654838&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 Fri May 9 07:56:53 2008
@@ -325,70 +325,82 @@
{
MojoDescriptor descriptor = (MojoDescriptor) it.next();
- String goal = descriptor.getFullGoalName();
- String description = StringUtils.isNotEmpty( descriptor.getDescription() ) ?
- StringUtils.escape( toText( descriptor.getDescription() ) ) : "No description available.";
+ writeGoal( writer, descriptor );
+ }
- writer.write( " sb.append( \"" + goal + "\" ).append( \"\\n\" );" + LS );
- writer.write( " appendDescription( sb, \"" + description + "\", DEFAULT_INDENT );" + LS );
+ // TODO Should be discovered
+ writer.write( " sb.append( \"" + getFullHelpGoalName( pluginDescriptor ) + "\" ).append( \"\\n\" );"
+ + LS );
+ writer.write( " appendDescription( sb, \"" + getHelpDescription( pluginDescriptor ) + "\", DEFAULT_INDENT );" + LS );
- if ( descriptor.getParameters() != null && descriptor.getParameters().size() > 0 )
- {
- writer.write( " if ( detail )" + LS );
- writer.write( " {" + LS );
+ writer.write( LS );
- writer.write( " sb.append( \"\\n\" );" + LS );
- writer.write( LS );
+ writer.write( " if ( getLog().isInfoEnabled() )" + LS );
+ writer.write( " {" + LS );
+ writer.write( " getLog().info( sb.toString() );" + LS );
+ writer.write( " }" + LS );
+ writer.write( " }" + LS );
+ }
- writer.write( " sb.append( repeat( \" \", 2 ) );" + LS );
- writer.write( " sb.append( \"Available parameters:\" ).append( \"\\n\" );" + LS );
- writer.write( LS );
- writer.write( " sb.append( \"\\n\" );" + LS );
- writer.write( LS );
+ private static void writeGoal( Writer writer, MojoDescriptor descriptor )
+ throws IOException
+ {
+ String goal = descriptor.getFullGoalName();
+ String description = StringUtils.isNotEmpty( descriptor.getDescription() ) ?
+ StringUtils.escape( toText( descriptor.getDescription() ) ) : "No description available.";
- for ( Iterator it2 = descriptor.getParameters().iterator(); it2.hasNext(); )
- {
- Parameter parameter = (Parameter) it2.next();
+ writer.write( " sb.append( \"" + goal + "\" ).append( \"\\n\" );" + LS );
+ writer.write( " appendDescription( sb, \"" + description + "\", DEFAULT_INDENT );" + LS );
- if ( parameter.isEditable() )
- {
- String expression = parameter.getExpression();
+ if ( descriptor.getParameters() != null && descriptor.getParameters().size() > 0 )
+ {
+ writer.write( " if ( detail )" + LS );
+ writer.write( " {" + LS );
- if ( expression == null || !expression.startsWith( "${component." ) )
- {
- String parameterName = parameter.getName();
- String parameterDescription = StringUtils.isNotEmpty( parameter.getDescription() ) ?
- StringUtils.escape( toText( parameter.getDescription() ) ) : "No description available.";
- String parameterDefaultValue = parameterName
- + ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) ? " (Default: '"
- + parameter.getDefaultValue() + "')" : "" );
+ writer.write( " sb.append( \"\\n\" );" + LS );
+ writer.write( LS );
- writer.write( " appendDescription( sb, \"" + parameterDefaultValue + "\", 4 );" + LS );
- writer.write( " appendDescription( sb, \"" + parameterDescription + "\", 6 );" + LS );
- }
- }
- }
+ writer.write( " sb.append( repeat( \" \", 2 ) );" + LS );
+ writer.write( " sb.append( \"Available parameters:\" ).append( \"\\n\" );" + LS );
+ writer.write( LS );
+ writer.write( " sb.append( \"\\n\" );" + LS );
+ writer.write( LS );
- writer.write( " }" + LS );
+ for ( Iterator it = descriptor.getParameters().iterator(); it.hasNext(); )
+ {
+ Parameter parameter = (Parameter) it.next();
+
+ if ( parameter.isEditable() )
+ {
+ writeParameter( writer, parameter );
+ }
}
- writer.write( LS );
- writer.write( " sb.append( \"\\n\" );" + LS );
- writer.write( LS );
+ writer.write( " }" + LS );
}
- // TODO Should be discovered
- writer.write( " sb.append( \"" + getFullHelpGoalName( pluginDescriptor ) + "\" ).append( \"\\n\" );"
- + LS );
- writer.write( " appendDescription( sb, \"" + getHelpDescription( pluginDescriptor ) + "\", DEFAULT_INDENT );" + LS );
-
writer.write( LS );
+ writer.write( " sb.append( \"\\n\" );" + LS );
+ writer.write( LS );
+ }
- writer.write( " if ( getLog().isInfoEnabled() )" + LS );
- writer.write( " {" + LS );
- writer.write( " getLog().info( sb.toString() );" + LS );
- writer.write( " }" + LS );
- writer.write( " }" + LS );
+ private static void writeParameter( Writer writer, Parameter parameter )
+ throws IOException
+ {
+ String expression = parameter.getExpression();
+
+ if ( expression == null || !expression.startsWith( "${component." ) )
+ {
+ String parameterName = parameter.getName();
+ String parameterDescription = StringUtils.isNotEmpty( parameter.getDescription() ) ?
+ StringUtils.escape( toText( parameter.getDescription() ) ) : "No description available.";
+ String parameterDefaultValue = parameterName
+ + ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) ? " (Default: '"
+ + parameter.getDefaultValue() + "')" : "" );
+
+ writer.write( " appendDescription( sb, \"" + parameterDefaultValue + "\", 4 );" + LS );
+ writer.write( " appendDescription( sb, \"" + parameterDescription + "\", 6 );" + LS );
+ }
}
private static void writeUtilities( Writer writer )