Author: vsiveton Date: Mon Jan 7 03:45:20 2008 New Revision: 609576 URL: http://svn.apache.org/viewvc?rev=609576&view=rev Log: MNG-2925: NullPointerException in PluginDescriptor.getMojo() if there's no mojo in pom.xml Submitted by: Kohsuke Kawaguchi Reviewed by: Vincent Siveton
o applied Modified: maven/components/branches/maven-2.0.x/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java Modified: maven/components/branches/maven-2.0.x/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java?rev=609576&r1=609575&r2=609576&view=diff ============================================================================== --- maven/components/branches/maven-2.0.x/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java (original) +++ maven/components/branches/maven-2.0.x/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java Mon Jan 7 03:45:20 2008 @@ -59,7 +59,7 @@ private boolean inheritedByDefault = true; private List artifacts; - + private Map lifecycleMappings; private ClassRealm classRealm; @@ -255,6 +255,11 @@ public MojoDescriptor getMojo( String goal ) { + if ( getMojos() == null ) + { + return null; // no mojo in this POM + } + // TODO: could we use a map? Maybe if the parent did that for components too, as this is too vulnerable to // changes above not being propogated to the map @@ -326,22 +331,22 @@ { return introducedDependencyArtifacts != null ? introducedDependencyArtifacts : Collections.EMPTY_SET; } - + public void setName( String name ) { this.name = name; } - + public String getName() { return name; } - + public void setDescription( String description ) { this.description = description; } - + public String getDescription() { return description;