o Refactored to reduce method size

git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@654838 13f79535-47bb-0310-9956-ffa450edef68
master
Benjamin Bentmann 2008-05-09 14:56:53 +00:00
parent 790e6439bb
commit fe9715f38d
1 changed files with 62 additions and 50 deletions

View File

@ -325,6 +325,26 @@ public class PluginHelpGenerator
{ {
MojoDescriptor descriptor = (MojoDescriptor) it.next(); MojoDescriptor descriptor = (MojoDescriptor) it.next();
writeGoal( writer, descriptor );
}
// 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( " if ( getLog().isInfoEnabled() )" + LS );
writer.write( " {" + LS );
writer.write( " getLog().info( sb.toString() );" + LS );
writer.write( " }" + LS );
writer.write( " }" + LS );
}
private static void writeGoal( Writer writer, MojoDescriptor descriptor )
throws IOException
{
String goal = descriptor.getFullGoalName(); String goal = descriptor.getFullGoalName();
String description = StringUtils.isNotEmpty( descriptor.getDescription() ) ? String description = StringUtils.isNotEmpty( descriptor.getDescription() ) ?
StringUtils.escape( toText( descriptor.getDescription() ) ) : "No description available."; StringUtils.escape( toText( descriptor.getDescription() ) ) : "No description available.";
@ -346,11 +366,26 @@ public class PluginHelpGenerator
writer.write( " sb.append( \"\\n\" );" + LS ); writer.write( " sb.append( \"\\n\" );" + LS );
writer.write( LS ); writer.write( LS );
for ( Iterator it2 = descriptor.getParameters().iterator(); it2.hasNext(); ) for ( Iterator it = descriptor.getParameters().iterator(); it.hasNext(); )
{ {
Parameter parameter = (Parameter) it2.next(); Parameter parameter = (Parameter) it.next();
if ( parameter.isEditable() ) if ( parameter.isEditable() )
{
writeParameter( writer, parameter );
}
}
writer.write( " }" + LS );
}
writer.write( LS );
writer.write( " sb.append( \"\\n\" );" + LS );
writer.write( LS );
}
private static void writeParameter( Writer writer, Parameter parameter )
throws IOException
{ {
String expression = parameter.getExpression(); String expression = parameter.getExpression();
@ -367,29 +402,6 @@ public class PluginHelpGenerator
writer.write( " appendDescription( sb, \"" + parameterDescription + "\", 6 );" + LS ); writer.write( " appendDescription( sb, \"" + parameterDescription + "\", 6 );" + LS );
} }
} }
}
writer.write( " }" + LS );
}
writer.write( LS );
writer.write( " sb.append( \"\\n\" );" + 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( " if ( getLog().isInfoEnabled() )" + LS );
writer.write( " {" + LS );
writer.write( " getLog().info( sb.toString() );" + LS );
writer.write( " }" + LS );
writer.write( " }" + LS );
}
private static void writeUtilities( Writer writer ) private static void writeUtilities( Writer writer )
throws IOException throws IOException