Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvladt2011-01-24 19:45:28 +0000
committervladt2011-01-24 19:45:28 +0000
commit5b79c1c13b4875026c83916131b1a748ec1d032a (patch)
treeb83e0186d8759aa7e0fdac2fad30fbf1a6661dd1
parent925c9b63de180056b3598d0b6de57c6a5ebfbc8e (diff)
downloadm2e-core-5b79c1c13b4875026c83916131b1a748ec1d032a.tar.gz
m2e-core-5b79c1c13b4875026c83916131b1a748ec1d032a.tar.xz
m2e-core-5b79c1c13b4875026c83916131b1a748ec1d032a.zip
335226: Validate that packaging types mapped in embedded lifecycle mapping configuration match the packaging type of the current project
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/Messages.java2
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecycle/LifecycleMappingFactory.java17
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/messages.properties1
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.

Back to the top