From a52a5e8623e8b71543eb586b440b54ce0c07b72b Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Mon, 3 Aug 2009 11:41:33 +0000 Subject: [PATCH] o Updated API to detect unknown/bad packagings git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@800315 13f79535-47bb-0310-9956-ffa450edef68 --- .../lifecycle/DefaultLifecycleExecutor.java | 18 ++++++++++-------- .../maven/lifecycle/LifecycleExecutor.java | 4 ++++ .../DefaultLifecycleBindingsInjector.java | 4 +++- 3 files changed, 17 insertions(+), 9 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 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() );