extracted writeGoal() and writeParameter() methods

git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1342986 13f79535-47bb-0310-9956-ffa450edef68
master
Herve Boutemy 2012-05-26 22:43:27 +00:00
parent 74a8581cc4
commit 7ddd1f2459
1 changed files with 51 additions and 36 deletions

View File

@ -152,20 +152,32 @@ public class HelpMojo
if ( goal == null || goal.length() <= 0 ) if ( goal == null || goal.length() <= 0 )
{ {
append( sb, "This plugin has " + mojos.length + " goals:", 0 ); append( sb, "This plugin has " + mojos.length + " goals:", 0 );
append( sb, "", 0 ); append( sb, "", 0 );
} }
for ( Xpp3Dom mojo : mojos ) for ( Xpp3Dom mojo : mojos )
{
writeGoal( sb, goalPrefix, mojo );
}
if ( getLog().isInfoEnabled() )
{
getLog().info( sb.toString() );
}
}
private void writeGoal( StringBuilder sb, String goalPrefix, Xpp3Dom mojo )
{ {
String mojoGoal = mojo.getChild( "goal" ).getValue(); String mojoGoal = mojo.getChild( "goal" ).getValue();
Xpp3Dom configurationElement = mojo.getChild( "configuration" ); Xpp3Dom configurationElement = mojo.getChild( "configuration" );
if ( goal == null || goal.length() <= 0 || mojoGoal.equals( goal ) ) if ( goal == null || goal.length() <= 0 || mojoGoal.equals( goal ) )
{ {
append( sb, goalPrefix + ":" + mojoGoal, 0 ); append( sb, goalPrefix + ":" + mojoGoal, 0 );
append( sb, mojo.getChild( "description" ).getValue(), 1 ); append( sb, mojo.getChild( "description" ).getValue(), 1 );
append( sb, "", 0 ); append( sb, "", 0 );
if ( detail ) if ( detail )
{ {
Xpp3Dom[] parameters = mojo.getChild( "parameters" ).getChildren( "parameter" ); Xpp3Dom[] parameters = mojo.getChild( "parameters" ).getChildren( "parameter" );
@ -177,29 +189,32 @@ public class HelpMojo
append( sb, "", 0 ); append( sb, "", 0 );
for ( Xpp3Dom parameter : parameters ) for ( Xpp3Dom parameter : parameters )
{
writeParameter( sb, parameter, configurationElement );
}
}
}
}
private void writeParameter( StringBuilder sb, Xpp3Dom parameter, Xpp3Dom configurationElement )
{ {
String name = parameter.getChild( "name" ).getValue(); String name = parameter.getChild( "name" ).getValue();
Xpp3Dom fieldConfigurationElement = configurationElement.getChild( name ); Xpp3Dom fieldConfigurationElement = configurationElement.getChild( name );
if ( fieldConfigurationElement != null && fieldConfigurationElement.getValue() != null ) if ( fieldConfigurationElement != null && fieldConfigurationElement.getValue() != null )
{ {
append( sb, name + " (default: " + configurationElement.getChild( name ).getAttribute( "default-value" ) + ")", 2 ); append( sb, name + " (default: " + configurationElement.getChild( name ).getAttribute( "default-value" ) + ")", 2 );
} }
append( sb, parameter.getChild( "description" ).getValue(), 3 ); append( sb, parameter.getChild( "description" ).getValue(), 3 );
if ( fieldConfigurationElement != null && fieldConfigurationElement.getValue() != null ) if ( fieldConfigurationElement != null && fieldConfigurationElement.getValue() != null )
{ {
append( sb, fieldConfigurationElement.getValue(), 3 ); append( sb, fieldConfigurationElement.getValue(), 3 );
} }
append( sb, "", 0 );
}
}
}
}
if ( getLog().isInfoEnabled() ) append( sb, "", 0 );
{
getLog().info( sb.toString() );
}
} }
/** /**