[MPLUGIN-210] NPE in generated help mojo with M2 when no goal has description

git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1345805 13f79535-47bb-0310-9956-ffa450edef68
master
Herve Boutemy 2012-06-03 23:39:34 +00:00
parent 7230ba93e3
commit 017a3d5ca6
1 changed files with 8 additions and 2 deletions

View File

@ -170,6 +170,12 @@ public class HelpMojo
} }
} }
private String getValue( Xpp3Dom mojo, String child )
{
Xpp3Dom elt = mojo.getChild( child );
return ( elt == null ) ? "" : elt.getValue();
}
private void writeGoal( StringBuilder sb, String goalPrefix, Xpp3Dom mojo ) private void writeGoal( StringBuilder sb, String goalPrefix, Xpp3Dom mojo )
{ {
String mojoGoal = mojo.getChild( "goal" ).getValue(); String mojoGoal = mojo.getChild( "goal" ).getValue();
@ -185,12 +191,12 @@ public class HelpMojo
if ( detail ) if ( detail )
{ {
append( sb, "", 0 ); append( sb, "", 0 );
append( sb, mojo.getChild( "description" ).getValue(), 1 ); append( sb, getValue( mojo, "description" ), 1 );
} }
} }
else else
{ {
append( sb, mojo.getChild( "description" ).getValue(), 1 ); append( sb, getValue( mojo, "description" ), 1 );
} }
append( sb, "", 0 ); append( sb, "", 0 );