diff --git a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java index 6a5ded1..695c776 100644 --- a/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java +++ b/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java @@ -263,8 +263,8 @@ public class PluginHelpGenerator writer.write( " /** 80-character display buffer */" + LS ); writer.write( " private static final int DEFAULT_WIDTH = 80;" + LS ); writer.write( LS ); - writer.write( " /** 4 indent spaces */" + LS ); - writer.write( " private static final String DEFAULT_INDENT = repeat( \" \", 2 );" + LS ); + writer.write( " /** 2 indent spaces */" + LS ); + writer.write( " private static final int DEFAULT_INDENT = 2;" + LS ); writer.write( LS ); writer.write( " /**" + LS ); writer.write( " * If true, display all settable properies for each goal." + LS ); @@ -300,11 +300,7 @@ public class PluginHelpGenerator StringUtils.escape( toText( descriptor.getDescription() ) ) : "No description available."; writer.write( " sb.append( \"" + goal + "\" ).append( \"\\n\" );" + LS ); - writer.write( " for ( Iterator it = toLines( \"" + description + "\" ).iterator(); it.hasNext(); )" - + LS ); - writer.write( " {" + LS ); - writer.write( " sb.append( it.next().toString() ).append( \"\\n\" );" + LS ); - writer.write( " }" + LS ); + writer.write( " appendDescription( sb, \"" + description + "\", DEFAULT_INDENT );" + LS ); if ( descriptor.getParameters() != null && descriptor.getParameters().size() > 0 ) { @@ -337,17 +333,8 @@ public class PluginHelpGenerator + ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) ? " (Default: '" + parameter.getDefaultValue() + "')" : "" ); - writer.write( " for ( Iterator it = toLines( \"" + parameterDefaultValue - + "\", repeat( \" \", 4 ), DEFAULT_WIDTH ).iterator(); it.hasNext(); )" + LS ); - writer.write( " {" + LS ); - writer.write( " sb.append( it.next().toString() ).append( \"\\n\" );" + LS ); - writer.write( " }" + LS ); - - writer.write( " for ( Iterator it = toLines( \"" + parameterDescription - + "\", repeat( \" \", 6 ), DEFAULT_WIDTH ).iterator(); it.hasNext(); )" + LS ); - writer.write( " {" + LS ); - writer.write( " sb.append( it.next().toString() ).append( \"\\n\" );" + LS ); - writer.write( " }" + LS ); + writer.write( " appendDescription( sb, \"" + parameterDefaultValue + "\", 4 );" + LS ); + writer.write( " appendDescription( sb, \"" + parameterDescription + "\", 6 );" + LS ); } } } @@ -363,11 +350,7 @@ public class PluginHelpGenerator // TODO Should be discovered writer.write( " sb.append( \"" + getFullHelpGoalName( pluginDescriptor ) + "\" ).append( \"\\n\" );" + LS ); - writer.write( " for ( Iterator it = toLines( \"" + getHelpDescription( pluginDescriptor ) - + "\" ).iterator(); it.hasNext(); )" + LS ); - writer.write( " {" + LS ); - writer.write( " sb.append( it.next().toString() ).append( \"\\n\" );" + LS ); - writer.write( " }" + LS ); + writer.write( " appendDescription( sb, \"" + getHelpDescription( pluginDescriptor ) + "\", DEFAULT_INDENT );" + LS ); writer.write( LS ); @@ -403,20 +386,6 @@ public class PluginHelpGenerator writer.write( " }" + LS ); writer.write( LS ); writer.write( " /**" + LS ); - writer.write( " *
Give a list of lines for the str. " + "Each line is indented by 4 spaces"
- + LS );
- writer.write( " * and has a maximum of 80 characters.
null" + LS );
- writer.write( " */" + LS );
- writer.write( " private static List toLines( String str )" + LS );
- writer.write( " {" + LS );
- writer.write( " return toLines( str, DEFAULT_INDENT, DEFAULT_WIDTH );" + LS );
- writer.write( " }" + LS );
- writer.write( LS );
- writer.write( " /**" + LS );
writer
.write( " * Give a list of lines for the str. Each line is indented by indent"
+ LS );
@@ -468,6 +437,14 @@ public class PluginHelpGenerator
writer.write( LS );
writer.write( " return sentences;" + LS );
writer.write( " }" + LS );
+ writer.write( LS );
+ writer.write( " private static void appendDescription( StringBuffer sb, String description, int indent )" + LS );
+ writer.write( " {" + LS );
+ writer.write( " for ( Iterator it = toLines( description, repeat( \" \", indent ), DEFAULT_WIDTH ).iterator(); it.hasNext(); )" + LS );
+ writer.write( " {" + LS );
+ writer.write( " sb.append( it.next().toString() ).append( \"\\n\" );" + LS );
+ writer.write( " }" + LS );
+ writer.write( " }" + LS );
}
/**