From 7bba85198e2140dd1287e27fdeed487a48d49d8d Mon Sep 17 00:00:00 2001 From: Emmanuel Venisse Date: Wed, 1 Jun 2005 09:08:04 +0000 Subject: [PATCH] Check if plugin contains some mojo, and send an exception instead of NullPointerException if it isn't the case. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@179369 13f79535-47bb-0310-9956-ffa450edef68 --- .../lifecycle/DefaultLifecycleExecutor.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java index f1e749eac6..8395fb5076 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java @@ -417,15 +417,25 @@ public class DefaultLifecycleExecutor MojoDescriptor mojoDescriptor = null; - // TODO: should be able to create a Map from this - for ( Iterator i = pluginDescriptor.getMojos().iterator(); i.hasNext() && mojoDescriptor == null; ) + if ( pluginDescriptor.getMojos() != null ) { - MojoDescriptor desc = (MojoDescriptor) i.next(); - if ( desc.getGoal().equals( goal ) ) + // TODO: should be able to create a Map from this + for ( Iterator i = pluginDescriptor.getMojos().iterator(); i.hasNext() && mojoDescriptor == null; ) { - mojoDescriptor = desc; + MojoDescriptor desc = (MojoDescriptor) i.next(); + if ( desc.getGoal().equals( goal ) ) + { + mojoDescriptor = desc; + } } } + else + { + throw new LifecycleExecutionException( "The plugin " + pluginDescriptor.getGroupId() + ":" + + pluginDescriptor.getArtifactId() + ":" + + pluginDescriptor.getVersion() + + " doesn't contain any mojo. Check if it isn't corrupted." ); + } if ( mojoDescriptor == null ) {