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 1726388f93..a6fe0ab15e 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 @@ -1025,17 +1025,19 @@ public class DefaultLifecycleExecutor // public Set getPluginsBoundByDefaultToAllLifecycles( String packaging ) { + LifecycleMapping lifecycleMappingForPackaging = lifecycleMappings.get( packaging ); + + if ( lifecycleMappingForPackaging == null ) + { + return null; + } + Map plugins = new LinkedHashMap(); - + for ( Lifecycle lifecycle : lifecycles ) { - LifecycleMapping lifecycleMappingForPackaging = lifecycleMappings.get( packaging ); - - org.apache.maven.lifecycle.mapping.Lifecycle lifecycleConfiguration = null; - if ( lifecycleMappingForPackaging != null ) - { - lifecycleConfiguration = lifecycleMappingForPackaging.getLifecycles().get( lifecycle.getId() ); - } + org.apache.maven.lifecycle.mapping.Lifecycle lifecycleConfiguration = + lifecycleMappingForPackaging.getLifecycles().get( lifecycle.getId() ); if ( lifecycleConfiguration != null ) { diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java index e3da7cead1..3ffe9fbd56 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java @@ -63,6 +63,10 @@ public interface LifecycleExecutor // We need to know the specific version so that we can lookup the right version of the plugin descriptor // which tells us what the default configuration is. // + /** + * @return The plugins bound to the lifecycles of the specified packaging or {@code null} if the packaging is + * unknown. + */ Set getPluginsBoundByDefaultToAllLifecycles( String packaging ); // Given a set of {@link org.apache.maven.Plugin} objects where the GAV is set we can lookup the plugin diff --git a/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java b/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java index 020d7adff6..2abd7dd0df 100644 --- a/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java +++ b/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java @@ -57,7 +57,9 @@ public class DefaultLifecycleBindingsInjector Collection defaultPlugins = lifecycle.getPluginsBoundByDefaultToAllLifecycles( packaging ); - if ( !defaultPlugins.isEmpty() ) + // TODO: A bad packaging is a model error, we need to report this as such! + + if ( defaultPlugins != null && !defaultPlugins.isEmpty() ) { Model lifecycleModel = new Model(); lifecycleModel.setBuild( new Build() );