diff options
3 files changed, 18 insertions, 2 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/Messages.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/Messages.java index 6c92b262..8c94bef0 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/Messages.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/Messages.java @@ -225,6 +225,8 @@ public class Messages extends NLS { public static String LifecycleMappingNotAvailable; + public static String LifecycleMappingPackagingMismatch; + public static String LifecycleMappingPluginVersionIncompatible; public static String PluginExecutionMappingDuplicate; diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecycle/LifecycleMappingFactory.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecycle/LifecycleMappingFactory.java index 2951759d..342ba630 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecycle/LifecycleMappingFactory.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecycle/LifecycleMappingFactory.java @@ -171,7 +171,7 @@ public class LifecycleMappingFactory { InvalidLifecycleMapping invalidLifecycleMapping = new InvalidLifecycleMapping(); // List order - // 1. this pom embedded, this pom referenced, parent embedded, parent referenced, grand parent embeded... + // 1. this pom embedded, this pom referenced, parent embedded, parent referenced, grand parent embedded... // 2. sources contributed by eclipse extensions // 3. default source, if present List<MappingMetadataSource> metadataSources = new ArrayList<MappingMetadataSource>(); @@ -484,19 +484,32 @@ public class LifecycleMappingFactory { Plugin metadataPlugin = pluginManagement.getPluginsAsMap().get(LIFECYCLE_MAPPING_PLUGIN_KEY); if(metadataPlugin != null) { checkCompatibleVersion(metadataPlugin); + Xpp3Dom configurationDom = (Xpp3Dom) metadataPlugin.getConfiguration(); if(configurationDom != null) { Xpp3Dom lifecycleMappingDom = configurationDom.getChild(ELEMENT_LIFECYCLE_MAPPING_METADATA); if(lifecycleMappingDom != null) { try { - return new LifecycleMappingMetadataSourceXpp3Reader() + LifecycleMappingMetadataSource metadataSource = new LifecycleMappingMetadataSourceXpp3Reader() .read(new StringReader(lifecycleMappingDom.toString())); + String packagingType = mavenProject.getPackaging(); + if(!"pom".equals(packagingType)) { //$NON-NLS-1$ + for(LifecycleMappingMetadata lifecycleMappingMetadata : metadataSource.getLifecycleMappings()) { + if(!packagingType.equals(lifecycleMappingMetadata.getPackagingType())) { + throw new LifecycleMappingConfigurationException(NLS.bind(Messages.LifecycleMappingPackagingMismatch, + lifecycleMappingMetadata.getPackagingType(), packagingType)); + } + } + } + return metadataSource; } catch(IOException e) { throw new LifecycleMappingConfigurationException( "Cannot read lifecycle mapping metadata for maven project " + mavenProject, e); } catch(XmlPullParserException e) { throw new LifecycleMappingConfigurationException( "Cannot parse lifecycle mapping metadata for maven project " + mavenProject, e); + } catch(LifecycleMappingConfigurationException e) { + throw e; } catch(RuntimeException e) { throw new LifecycleMappingConfigurationException( "Cannot load lifecycle mapping metadata for maven project " + mavenProject, e); diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/messages.properties b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/messages.properties index cbfc7a0c..b90a924c 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/messages.properties +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/messages.properties @@ -100,6 +100,7 @@ LifecycleConfigurationMojoExecutionErrorMessage=Mojo execution marked as error i LifecycleMissing=Unknown or missing lifecycle mapping (project packaging type="{0}") LifecycleDuplicate=Conflicting lifecycle mapping metadata (project packaging type="{0}"). To enable full functionality, remove the conflicting mapping and run Maven->Update Project Configuration. LifecycleMappingNotAvailable=Lifecycle mapping "{0}" is not available. To enable full functionality, install the lifecycle mapping and run Maven->Update Project Configuration. +LifecycleMappingPackagingMismatch=Packaging type {0} configured in embedded lifecycle mapping configuration does not match the packaging type {1} of the current project. LifecycleMappingPluginVersionIncompatible=Incompatible lifecycle mapping plugin version {0} PluginExecutionMappingDuplicate=Conflicting lifecycle mapping (plugin execution "{0}"). To enable full functionality, remove the conflicting mapping and run Maven->Update Project Configuration. ProjectConfiguratorNotAvailable=Project configurator "{0}" is not available. To enable full functionality, install the project configurator and run Maven->Update Project Configuration. |