From 1a4c003a2bbe04cb18a61adc1bae09133066a116 Mon Sep 17 00:00:00 2001 From: Jason van Zyl Date: Sun, 15 Jun 2014 17:05:45 -0400 Subject: [PATCH] MNG-5349: Make sure lifecycles have and id. When we switch to JSR330 I would prefer to use private final fields in Lifecycle.java and use the Precondition.assertNotNull check. This will serve for now. --- .../org/apache/maven/lifecycle/DefaultLifecycles.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java index d5fae6c35d..64c9a7f9c4 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java @@ -24,6 +24,8 @@ import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; +import com.google.common.base.Preconditions; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -119,7 +121,9 @@ public class DefaultLifecycles ArrayList result = new ArrayList(); for ( String name : lifecycleNames ) { - result.add( lifecycles.get( name ) ); + Lifecycle lifecycle = lifecycles.get( name ); + Preconditions.checkNotNull( "A lifecycle must have an id.", lifecycle.getId() ); + result.add( lifecycle ); } return result; @@ -129,7 +133,7 @@ public class DefaultLifecycles { Set phases = new LinkedHashSet(); - for ( Lifecycle lifecycle : lifecycles.values() ) + for ( Lifecycle lifecycle : getLifeCycles() ) { phases.addAll( lifecycle.getPhases() ); }