[
http://jira.codehaus.org/browse/MNG-2925?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Vincent Siveton closed MNG-2925.
--------------------------------
Assignee: Vincent Siveton
Resolution: Fixed
Fix Version/s: (was: Reviewed Pending Version Assignment)
2.1-alpha-1
2.0.9
Applied in r609576
For the next time, please provide us a patch.
http://maven.apache.org/guides/development/guide-m2-development.html#Creating_and_submitting_a_patch
> NullPointerException in PluginDescriptor.getMojo() if there's no mojo in
> pom.xml
> --------------------------------------------------------------------------------
>
> Key: MNG-2925
> URL: http://jira.codehaus.org/browse/MNG-2925
> Project: Maven 2
> Issue Type: Bug
> Components: Plugin API
> Affects Versions: 2.0.5
> Reporter: Kohsuke Kawaguchi
> Assignee: Vincent Siveton
> Fix For: 2.0.9, 2.1-alpha-1
>
>
> The getMojo method fails with NPE because getMojos() method returns null.
> This happens when there's no mojo in the plugin.
> The code should be modified to check for this situation, like this:
> {code}
> public MojoDescriptor getMojo( String goal )
> {
> List mojos = getMojos();
> if(mojos==null) return null; // no mojo in this POM
> MojoDescriptor mojoDescriptor = null;
> for ( Iterator i = mojos.iterator(); i.hasNext() && mojoDescriptor ==
> null; )
> {
> MojoDescriptor desc = (MojoDescriptor) i.next();
> if ( goal.equals( desc.getGoal() ) )
> {
> mojoDescriptor = desc;
> }
> }
> return mojoDescriptor;
> }
> {/code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira