From 017a3d5ca6ed91bdb3739d0c2924c8635f784af2 Mon Sep 17 00:00:00 2001 From: Herve Boutemy Date: Sun, 3 Jun 2012 23:39:34 +0000 Subject: [PATCH] [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 --- .../src/main/resources/help-class-source.vm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/maven-plugin-tools-generators/src/main/resources/help-class-source.vm b/maven-plugin-tools-generators/src/main/resources/help-class-source.vm index d96460a..361e321 100644 --- a/maven-plugin-tools-generators/src/main/resources/help-class-source.vm +++ b/maven-plugin-tools-generators/src/main/resources/help-class-source.vm @@ -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 ) { String mojoGoal = mojo.getChild( "goal" ).getValue(); @@ -185,12 +191,12 @@ public class HelpMojo if ( detail ) { append( sb, "", 0 ); - append( sb, mojo.getChild( "description" ).getValue(), 1 ); + append( sb, getValue( mojo, "description" ), 1 ); } } else { - append( sb, mojo.getChild( "description" ).getValue(), 1 ); + append( sb, getValue( mojo, "description" ), 1 ); } append( sb, "", 0 );