Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2011-03-07 12:28:28 -0500
committerIgor Fedorenko2011-03-07 12:28:28 -0500
commit613458d7b452941a4d30828d255844165ce13fdc (patch)
tree870c7a4bdff100e3dd551e374eb732ef25f1b070
parent73fc418a25f3812d71487714c1521ded83db6be0 (diff)
downloadm2e-core-613458d7b452941a4d30828d255844165ce13fdc.tar.gz
m2e-core-613458d7b452941a4d30828d255844165ce13fdc.tar.xz
m2e-core-613458d7b452941a4d30828d255844165ce13fdc.zip
335701 discover lifecycleMapping and project configiguration extensions
Discover and offer installation of m2e extensions providing lifecycleMapping and project configiguration implementations. Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/AggregateMappingLabelProvider.java27
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/ILifecycleMappingLabelProvider.java7
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/MojoExecutionMappingLabelProvider.java76
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/PackagingTypeMappingLabelProvider.java14
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/ProjectLifecycleMappingElement.java36
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java46
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizard.java19
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java5
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/LifecycleMappingFactory.java61
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/ILifecycleMappingElement.java (renamed from org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/ILifecycleMappingElementKey.java)5
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/ILifecycleMappingRequirement.java25
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/IMavenDiscovery.java2
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/LifecycleMappingConfiguration.java (renamed from org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/LifecycleMappingConfiguration.java)244
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/MojoExecutionMappingConfiguration.java166
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/PackagingTypeMappingConfiguration.java101
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/MojoExecutionKey.java15
-rw-r--r--org.eclipse.m2e.discovery-directory/org.eclipse.m2e.discovery.oss/lifecycle/org.eclipse.m2e.discovery.lifecyclemapping.plexus-annotations.pluginxml15
-rw-r--r--org.eclipse.m2e.discovery-directory/org.eclipse.m2e.discovery.oss/lifecycle/org.eclipse.m2e.discovery.lifecyclemapping.temporary-mojos.pluginxml30
-rw-r--r--org.eclipse.m2e.discovery-directory/org.eclipse.m2e.discovery.oss/lifecycle/org.eclipse.m2e.discovery.lifecycles.tycho.pluginxml31
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/InstallCatalogItemMappingLabelProvider.java18
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscovery.java58
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java77
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogViewer.java9
23 files changed, 766 insertions, 321 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/AggregateMappingLabelProvider.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/AggregateMappingLabelProvider.java
index aa522488..76fc9b65 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/AggregateMappingLabelProvider.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/AggregateMappingLabelProvider.java
@@ -10,7 +10,9 @@ package org.eclipse.m2e.core.ui.internal.lifecyclemapping;
import java.util.List;
-import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingElementKey;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingElement;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingRequirement;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.LifecycleMappingConfiguration;
import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.MojoExecutionMappingConfiguration;
import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.PackagingTypeMappingConfiguration;
import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
@@ -21,24 +23,25 @@ import org.eclipse.osgi.util.NLS;
*
* @author mkleint
*/
+@SuppressWarnings("restriction")
public class AggregateMappingLabelProvider implements ILifecycleMappingLabelProvider {
private final List<ILifecycleMappingLabelProvider> content;
- private final ILifecycleMappingElementKey key;
+ private final ILifecycleMappingElement element;
- public AggregateMappingLabelProvider(ILifecycleMappingElementKey key, List<ILifecycleMappingLabelProvider> content) {
+ public AggregateMappingLabelProvider(ILifecycleMappingElement element, List<ILifecycleMappingLabelProvider> content) {
this.content = content;
- this.key = key;
+ this.element = element;
}
/* (non-Javadoc)
* @see org.eclipse.m2e.core.ui.internal.lifecyclemapping.ILifecycleMappingLabelProvider#getMavenText()
*/
public String getMavenText() {
- if(key instanceof PackagingTypeMappingConfiguration.Key) {
- return NLS.bind("Packaging {0}", ((PackagingTypeMappingConfiguration.Key) key).getPackaging());
+ if(element instanceof PackagingTypeMappingConfiguration) {
+ return NLS.bind("Packaging {0}", ((PackagingTypeMappingConfiguration) element).getPackaging());
}
- if(key instanceof MojoExecutionMappingConfiguration.Key) {
- MojoExecutionKey exec = ((MojoExecutionMappingConfiguration.Key) key).getExecution();
+ if(element instanceof MojoExecutionMappingConfiguration) {
+ MojoExecutionKey exec = ((MojoExecutionMappingConfiguration) element).getExecution();
return exec.getArtifactId() + ":" + exec.getVersion() + ":" + exec.getGoal(); //TODO
}
throw new IllegalStateException();
@@ -64,9 +67,9 @@ public class AggregateMappingLabelProvider implements ILifecycleMappingLabelProv
/* (non-Javadoc)
* @see org.eclipse.m2e.core.ui.internal.lifecyclemapping.ILifecycleMappingLabelProvider#isError()
*/
- public boolean isError() {
+ public boolean isError(LifecycleMappingConfiguration mappingConfiguration) {
for (ILifecycleMappingLabelProvider pr : content) {
- if (pr.isError()) {
+ if (pr.isError(mappingConfiguration)) {
return true;
}
}
@@ -81,8 +84,8 @@ public class AggregateMappingLabelProvider implements ILifecycleMappingLabelProv
/* (non-Javadoc)
* @see org.eclipse.m2e.core.ui.internal.lifecyclemapping.ILifecycleMappingLabelProvider#getKey()
*/
- public ILifecycleMappingElementKey getKey() {
- return key;
+ public ILifecycleMappingRequirement getKey() {
+ return element.getLifecycleMappingRequirement();
}
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/ILifecycleMappingLabelProvider.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/ILifecycleMappingLabelProvider.java
index dc4cc3c5..be40f2d2 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/ILifecycleMappingLabelProvider.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/ILifecycleMappingLabelProvider.java
@@ -8,7 +8,8 @@
package org.eclipse.m2e.core.ui.internal.lifecyclemapping;
-import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingElementKey;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingRequirement;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.LifecycleMappingConfiguration;
/**
* ILifecycleMappingLabelProvider
@@ -29,7 +30,7 @@ public interface ILifecycleMappingLabelProvider {
*/
public String getEclipseMappingText(LifecycleMappingConfiguration mappingConfiguration);
- public boolean isError();
+ public boolean isError(LifecycleMappingConfiguration mappingConfiguration);
- public ILifecycleMappingElementKey getKey();
+ public ILifecycleMappingRequirement getKey();
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/MojoExecutionMappingLabelProvider.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/MojoExecutionMappingLabelProvider.java
index 84e176e3..0bc16207 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/MojoExecutionMappingLabelProvider.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/MojoExecutionMappingLabelProvider.java
@@ -9,11 +9,11 @@
package org.eclipse.m2e.core.ui.internal.lifecyclemapping;
import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory;
-import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingElementKey;
-import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.IMavenDiscoveryProposal;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingRequirement;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.LifecycleMappingConfiguration;
import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.MojoExecutionMappingConfiguration;
-import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.MojoExecutionMappingConfiguration.MojoExecutionMappingInfo;
import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ProjectLifecycleMappingConfiguration;
+import org.eclipse.m2e.core.internal.lifecyclemapping.model.PluginExecutionMetadata;
import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
import org.eclipse.osgi.util.NLS;
@@ -45,29 +45,28 @@ public class MojoExecutionMappingLabelProvider implements ILifecycleMappingLabel
public String getEclipseMappingText(LifecycleMappingConfiguration mappingConfiguration) {
StringBuilder sb = new StringBuilder();
- if(element.getMappings().isEmpty()) {
+ PluginExecutionMetadata mapping = element.getMapping();
+ if(mapping == null) {
if(LifecycleMappingFactory.isInterestingPhase(element.getExecution().getLifecyclePhase())) {
sb.append("Not covered");
}
} else {
- for(MojoExecutionMappingInfo mapping : element.getMappings()) {
- switch(mapping.getMapping().getAction()) {
- case configurator:
- if(mapping.getConfigurator() == null) {
- sb.append("Missing Connector '").append(
- LifecycleMappingFactory.getProjectConfiguratorId(mapping.getMapping()) + "'");
- }
- break;
- case execute:
- sb.append("Executing Maven goal");
- break;
- case error:
- sb.append("Not supported - ").append(LifecycleMappingFactory.getActionMessage(mapping.getMapping()));
- break;
- case ignore:
- sb.append("Ignoring");
- break;
- }
+ switch(mapping.getAction()) {
+ case configurator:
+ ILifecycleMappingRequirement requirement = element.getLifecycleMappingRequirement();
+ if(!mappingConfiguration.isRequirementSatisfied(requirement, true)) {
+ sb.append("Missing Connector '").append(LifecycleMappingFactory.getProjectConfiguratorId(mapping) + "'");
+ }
+ break;
+ case execute:
+ sb.append("Executing Maven goal");
+ break;
+ case error:
+ sb.append("Not supported - ").append(LifecycleMappingFactory.getActionMessage(mapping));
+ break;
+ case ignore:
+ sb.append("Ignoring");
+ break;
}
}
@@ -77,38 +76,15 @@ public class MojoExecutionMappingLabelProvider implements ILifecycleMappingLabel
/* (non-Javadoc)
* @see org.eclipse.m2e.core.ui.internal.lifecyclemapping.ILifecycleMappingLabelProvider#isError()
*/
- public boolean isError() {
- if(element.getMappings().isEmpty()) {
- if(LifecycleMappingFactory.isInterestingPhase(element.getExecution().getLifecyclePhase())) {
- return true;
- } else {
- return false;
- }
- } else {
- for(MojoExecutionMappingInfo mapping : element.getMappings()) {
- switch(mapping.getMapping().getAction()) {
- case configurator:
- if(mapping.getConfigurator() == null) {
- return true;
- } else {
- return false;
- }
- case execute:
- return false;
- case error:
- return true;
- case ignore:
- return false;
- }
- }
- }
- return false;
+ public boolean isError(LifecycleMappingConfiguration mappingConfiguration) {
+ ILifecycleMappingRequirement requirement = element.getLifecycleMappingRequirement();
+ return !mappingConfiguration.isRequirementSatisfied(requirement, true);
}
/* (non-Javadoc)
* @see org.eclipse.m2e.core.ui.internal.lifecyclemapping.ILifecycleMappingLabelProvider#getKey()
*/
- public ILifecycleMappingElementKey getKey() {
- return element.getLifecycleMappingElementKey();
+ public ILifecycleMappingRequirement getKey() {
+ return element.getLifecycleMappingRequirement();
}
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/PackagingTypeMappingLabelProvider.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/PackagingTypeMappingLabelProvider.java
index 2699e70d..0443f4d0 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/PackagingTypeMappingLabelProvider.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/PackagingTypeMappingLabelProvider.java
@@ -8,10 +8,10 @@
package org.eclipse.m2e.core.ui.internal.lifecyclemapping;
-import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingElementKey;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingRequirement;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.LifecycleMappingConfiguration;
import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.PackagingTypeMappingConfiguration;
import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ProjectLifecycleMappingConfiguration;
-import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
import org.eclipse.osgi.util.NLS;
@@ -39,7 +39,7 @@ public class PackagingTypeMappingLabelProvider implements ILifecycleMappingLabel
StringBuilder sb = new StringBuilder();
if(element.getLifecycleMappingId() == null) {
return "No recognized handling";
- } else if(element.getLifecycleMapping() == null) {
+ } else if(element.getLifecycleMappingId() == null) {
return NLS.bind("Handling with id {0} not found", element.getLifecycleMappingId());
}
return sb.toString();
@@ -48,10 +48,10 @@ public class PackagingTypeMappingLabelProvider implements ILifecycleMappingLabel
/* (non-Javadoc)
* @see org.eclipse.m2e.core.ui.internal.lifecyclemapping.ILifecycleMappingLabelProvider#isError()
*/
- public boolean isError() {
+ public boolean isError(LifecycleMappingConfiguration mappingConfiguration) {
if(element.getLifecycleMappingId() == null) {
return true;
- } else if(element.getLifecycleMapping() == null) {
+ } else if(element.getLifecycleMappingId() == null) {
return true;
} else {
return false;
@@ -62,8 +62,8 @@ public class PackagingTypeMappingLabelProvider implements ILifecycleMappingLabel
/* (non-Javadoc)
* @see org.eclipse.m2e.core.ui.internal.lifecyclemapping.ILifecycleMappingLabelProvider#getKey()
*/
- public ILifecycleMappingElementKey getKey() {
- return element.getLifecycleMappingElementKey();
+ public ILifecycleMappingRequirement getKey() {
+ return element.getLifecycleMappingRequirement();
}
}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/ProjectLifecycleMappingElement.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/ProjectLifecycleMappingElement.java
new file mode 100644
index 00000000..4691d5aa
--- /dev/null
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/ProjectLifecycleMappingElement.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Sonatype, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.m2e.core.ui.internal.lifecyclemapping;
+
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingElement;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ProjectLifecycleMappingConfiguration;
+
+
+/**
+ * Represents instance of ILifecycleMappingElement within context of specific ProjectLifecycleMappingConfiguration
+ */
+@SuppressWarnings("restriction")
+public class ProjectLifecycleMappingElement {
+ private final ProjectLifecycleMappingConfiguration project;
+
+ private final ILifecycleMappingElement element;
+
+ public ProjectLifecycleMappingElement(ProjectLifecycleMappingConfiguration project, ILifecycleMappingElement element) {
+ this.project = project;
+ this.element = element;
+ }
+
+ public ProjectLifecycleMappingConfiguration getProject() {
+ return project;
+ }
+
+ public ILifecycleMappingElement getElement() {
+ return element;
+ }
+}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java
index 65cd1a38..067106bd 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/LifecycleMappingPage.java
@@ -35,9 +35,12 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.m2e.core.MavenPlugin;
-import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingElementKey;
+import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingElement;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingRequirement;
import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.IMavenDiscovery;
import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.IMavenDiscoveryProposal;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.LifecycleMappingConfiguration;
import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.MojoExecutionMappingConfiguration;
import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.PackagingTypeMappingConfiguration;
import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ProjectLifecycleMappingConfiguration;
@@ -47,7 +50,6 @@ import org.eclipse.m2e.core.ui.internal.MavenImages;
import org.eclipse.m2e.core.ui.internal.Messages;
import org.eclipse.m2e.core.ui.internal.lifecyclemapping.AggregateMappingLabelProvider;
import org.eclipse.m2e.core.ui.internal.lifecyclemapping.ILifecycleMappingLabelProvider;
-import org.eclipse.m2e.core.ui.internal.lifecyclemapping.LifecycleMappingConfiguration;
import org.eclipse.m2e.core.ui.internal.lifecyclemapping.MojoExecutionMappingLabelProvider;
import org.eclipse.m2e.core.ui.internal.lifecyclemapping.PackagingTypeMappingLabelProvider;
import org.eclipse.osgi.util.NLS;
@@ -198,27 +200,33 @@ public class LifecycleMappingPage extends WizardPage {
public Object[] getElements(Object inputElement) {
if(inputElement instanceof LifecycleMappingConfiguration) {
- Map<ILifecycleMappingElementKey, List<ILifecycleMappingLabelProvider>> packagings = new HashMap<ILifecycleMappingElementKey, List<ILifecycleMappingLabelProvider>>();
- Map<ILifecycleMappingElementKey, List<ILifecycleMappingLabelProvider>> mojos = new HashMap<ILifecycleMappingElementKey, List<ILifecycleMappingLabelProvider>>();
+ Map<ILifecycleMappingElement, List<ILifecycleMappingLabelProvider>> packagings = new HashMap<ILifecycleMappingElement, List<ILifecycleMappingLabelProvider>>();
+ Map<ILifecycleMappingElement, List<ILifecycleMappingLabelProvider>> mojos = new HashMap<ILifecycleMappingElement, List<ILifecycleMappingLabelProvider>>();
Collection<ProjectLifecycleMappingConfiguration> projects = ((LifecycleMappingConfiguration) inputElement).getProjects();
for (ProjectLifecycleMappingConfiguration prjconf : projects) {
PackagingTypeMappingConfiguration pack = prjconf.getPackagingTypeMappingConfiguration();
- if (pack != null && !pack.isOK()) {
- List<ILifecycleMappingLabelProvider> val = packagings.get(pack.getLifecycleMappingElementKey());
- if (val == null) {
- val = new ArrayList<ILifecycleMappingLabelProvider>();
- packagings.put(pack.getLifecycleMappingElementKey(), val);
+ if (pack != null) {
+ ILifecycleMappingRequirement packReq = pack.getLifecycleMappingRequirement();
+ if(!mappingConfiguration.getProposals(packReq).isEmpty()) {
+ List<ILifecycleMappingLabelProvider> val = packagings.get(pack);
+ if (val == null) {
+ val = new ArrayList<ILifecycleMappingLabelProvider>();
+ packagings.put(pack, val);
+ }
+ val.add(new PackagingTypeMappingLabelProvider(prjconf, pack));
}
- val.add(new PackagingTypeMappingLabelProvider(prjconf, pack));
}
List<MojoExecutionMappingConfiguration> mojoExecs = prjconf.getMojoExecutionConfigurations();
if (mojoExecs != null) {
for (MojoExecutionMappingConfiguration mojoMap : mojoExecs) {
- if (!mojoMap.isOK()) {
- List<ILifecycleMappingLabelProvider> val = mojos.get(mojoMap.getLifecycleMappingElementKey());
+ ILifecycleMappingRequirement mojoReq = mojoMap.getLifecycleMappingRequirement();
+ if(LifecycleMappingFactory.isInterestingPhase(mojoMap.getExecution().getLifecyclePhase())
+ && (!mappingConfiguration.isRequirementSatisfied(mojoReq, true) || !mappingConfiguration
+ .getProposals(mojoReq).isEmpty())) {
+ List<ILifecycleMappingLabelProvider> val = mojos.get(mojoMap);
if (val == null) {
val = new ArrayList<ILifecycleMappingLabelProvider>();
- mojos.put(mojoMap.getLifecycleMappingElementKey(), val);
+ mojos.put(mojoMap, val);
}
val.add(new MojoExecutionMappingLabelProvider(prjconf, mojoMap));
}
@@ -226,10 +234,10 @@ public class LifecycleMappingPage extends WizardPage {
}
}
List<ILifecycleMappingLabelProvider> toRet = new ArrayList<ILifecycleMappingLabelProvider>();
- for (Map.Entry<ILifecycleMappingElementKey, List<ILifecycleMappingLabelProvider>> ent : packagings.entrySet()) {
+ for (Map.Entry<ILifecycleMappingElement, List<ILifecycleMappingLabelProvider>> ent : packagings.entrySet()) {
toRet.add(new AggregateMappingLabelProvider(ent.getKey(), ent.getValue()));
}
- for (Map.Entry<ILifecycleMappingElementKey, List<ILifecycleMappingLabelProvider>> ent : mojos.entrySet()) {
+ for (Map.Entry<ILifecycleMappingElement, List<ILifecycleMappingLabelProvider>> ent : mojos.entrySet()) {
toRet.add(new AggregateMappingLabelProvider(ent.getKey(), ent.getValue()));
}
return toRet.toArray();
@@ -302,7 +310,7 @@ public class LifecycleMappingPage extends WizardPage {
public Image getColumnImage(Object element, int columnIndex) {
if(element instanceof ILifecycleMappingLabelProvider) {
ILifecycleMappingLabelProvider prov = (ILifecycleMappingLabelProvider)element;
- if (columnIndex == 0 && prov.isError()) {
+ if (columnIndex == 0 && prov.isError(mappingConfiguration)) {
if (mappingConfiguration.getSelectedProposal(prov.getKey()) == null) {
return MavenImages.IMG_ERROR;
} else {
@@ -370,7 +378,7 @@ public class LifecycleMappingPage extends WizardPage {
Collection<ProjectLifecycleMappingConfiguration> projects = mappingConfiguration.getProjects();
monitor.beginTask("Searching m2e marketplace", projects.size());
- Map<ILifecycleMappingElementKey, List<IMavenDiscoveryProposal>> proposals = new LinkedHashMap<ILifecycleMappingElementKey, List<IMavenDiscoveryProposal>>();
+ Map<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>> proposals = new LinkedHashMap<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>>();
for(ProjectLifecycleMappingConfiguration project : projects) {
if(monitor.isCanceled()) {
@@ -464,9 +472,9 @@ public class LifecycleMappingPage extends WizardPage {
public void setVisible(boolean visible) {
super.setVisible(visible);
if(visible) {
- mappingConfiguration = getMappingConfiguration();
+ mappingConfiguration = ((MavenImportWizard) getWizard()).getMappingConfiguration();
treeViewer.setInput(mappingConfiguration);
-
+
//set initial column sizes
TreeColumn[] columns = treeViewer.getTree().getColumns();
for (int i = 0; i < columns.length; i++) {
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizard.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizard.java
index 989a6ef3..16a6e6d5 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizard.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizard.java
@@ -28,12 +28,12 @@ import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.IMavenDiscovery;
import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.IMavenDiscoveryProposal;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.LifecycleMappingConfiguration;
import org.eclipse.m2e.core.project.IMavenProjectImportResult;
import org.eclipse.m2e.core.project.MavenProjectInfo;
import org.eclipse.m2e.core.project.ProjectImportConfiguration;
import org.eclipse.m2e.core.ui.internal.Messages;
import org.eclipse.m2e.core.ui.internal.actions.SelectionUtil;
-import org.eclipse.m2e.core.ui.internal.lifecyclemapping.LifecycleMappingConfiguration;
import org.eclipse.ui.IImportWizard;
import org.eclipse.ui.IWorkbench;
import org.slf4j.Logger;
@@ -174,7 +174,7 @@ public class MavenImportWizard extends AbstractMavenProjectWizard implements IIm
return false;
}
}
- return super.canFinish();
+ return false; //super.canFinish();
}
/*
@@ -201,21 +201,12 @@ public class MavenImportWizard extends AbstractMavenProjectWizard implements IIm
}
/**
- * @return null or a clone
+ * @return mapping configuration or null
*/
public LifecycleMappingConfiguration getMappingConfiguration() {
- if (mappingConfiguration != null) {
- return LifecycleMappingConfiguration.clone(mappingConfiguration, getProjects());
- }
- return null;
+ return mappingConfiguration;
}
-
- /**
- * @param list
- * @throws InterruptedException
- * @throws InvocationTargetException
- *
- */
+
void scanProjects(final List<MavenProjectInfo> list, IProgressMonitor monitor) throws CoreException {
LOG.debug("About to calculate lifecycle mapping configuration");
ProjectImportConfiguration importConfiguration = getProjectImportConfiguration();
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java
index 90611fff..ba8a6525 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/wizards/MavenImportWizardPage.java
@@ -42,12 +42,12 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.MavenModelManager;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.LifecycleMappingConfiguration;
import org.eclipse.m2e.core.project.AbstractProjectScanner;
import org.eclipse.m2e.core.project.LocalProjectScanner;
import org.eclipse.m2e.core.project.MavenProjectInfo;
import org.eclipse.m2e.core.project.ProjectImportConfiguration;
import org.eclipse.m2e.core.ui.internal.Messages;
-import org.eclipse.m2e.core.ui.internal.lifecyclemapping.LifecycleMappingConfiguration;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
@@ -204,6 +204,7 @@ public class MavenImportWizardPage extends AbstractMavenWizardPage {
updateCheckedState();
Object[] checkedElements = projectTreeViewer.getCheckedElements();
setPageComplete(checkedElements != null && checkedElements.length > 0);
+ ((MavenImportWizard) getWizard()).getMappingConfiguration().setSelectedProjects(getProjects());
}
});
@@ -525,7 +526,7 @@ public class MavenImportWizardPage extends AbstractMavenWizardPage {
IWizardPage next = super.getNextPage();
MavenImportWizard wizard = (MavenImportWizard)getWizard();
LifecycleMappingConfiguration config = wizard.getMappingConfiguration();
- if (config == null || config.isMappingComplete()) {
+ if (config == null || (config.isMappingComplete(true) && config.getAllProposals().isEmpty())) {
next = null;
}
return next;
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/LifecycleMappingFactory.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/LifecycleMappingFactory.java
index 54ceb028..1137beff 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/LifecycleMappingFactory.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/LifecycleMappingFactory.java
@@ -104,9 +104,9 @@ public class LifecycleMappingFactory {
private static final String LIFECYCLE_MAPPING_METADATA_SOURCE_PATH = "/lifecycle-mapping-metadata.xml";
- private static final String EXTENSION_LIFECYCLE_MAPPINGS = IMavenConstants.PLUGIN_ID + ".lifecycleMappings"; //$NON-NLS-1$
+ public static final String EXTENSION_LIFECYCLE_MAPPINGS = IMavenConstants.PLUGIN_ID + ".lifecycleMappings"; //$NON-NLS-1$
- private static final String EXTENSION_PROJECT_CONFIGURATORS = IMavenConstants.PLUGIN_ID + ".projectConfigurators"; //$NON-NLS-1$
+ public static final String EXTENSION_PROJECT_CONFIGURATORS = IMavenConstants.PLUGIN_ID + ".projectConfigurators"; //$NON-NLS-1$
private static final String EXTENSION_LIFECYCLE_MAPPING_METADATA_SOURCE = IMavenConstants.PLUGIN_ID
+ ".lifecycleMappingMetadataSource"; //$NON-NLS-1$
@@ -199,7 +199,8 @@ public class LifecycleMappingFactory {
return;
}
- calculateEffectiveLifecycleMappingMetadata(result, templateRequest, metadataSources, mavenProject, mojoExecutions);
+ calculateEffectiveLifecycleMappingMetadata(result, templateRequest, metadataSources, mavenProject, mojoExecutions,
+ true);
}
public static List<MappingMetadataSource> getProjectMetadataSources(MavenExecutionRequest templateRequest,
@@ -211,9 +212,11 @@ public class LifecycleMappingFactory {
// 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
+ // TODO validate metadata and replace invalid entries with error mapping
for(LifecycleMappingMetadataSource source : getPomMappingMetadataSources(mavenProject, templateRequest, monitor)) {
metadataSources.add(new SimpleMappingMetadataSource(source));
}
+ // TODO filter out invalid metadata from sources contributed by eclipse extensions and the default source
metadataSources.add(new SimpleMappingMetadataSource(bundleMetadataSources));
LifecycleMappingMetadataSource defaultSource = getDefaultLifecycleMappingMetadataSource();
if(defaultSource != null) {
@@ -225,7 +228,7 @@ public class LifecycleMappingFactory {
public static void calculateEffectiveLifecycleMappingMetadata(LifecycleMappingResult result,
MavenExecutionRequest templateRequest, List<MappingMetadataSource> metadataSources, MavenProject mavenProject,
- List<MojoExecution> mojoExecutions) {
+ List<MojoExecution> mojoExecutions, boolean applyDefaultStrategy) {
IMaven maven = MavenPlugin.getDefault().getMaven();
MavenSession session = maven.createSession(newMavenExecutionRequest(templateRequest), mavenProject);
@@ -253,12 +256,14 @@ public class LifecycleMappingFactory {
}
}
- if(lifecycleMappingMetadata == null) {
+ if(lifecycleMappingMetadata == null && applyDefaultStrategy) {
lifecycleMappingMetadata = new LifecycleMappingMetadata();
lifecycleMappingMetadata.setLifecycleMappingId("DEFAULT"); // TODO proper constant
lifecycleMappingMetadata.setPackagingType(mavenProject.getPackaging());
}
+ // TODO if lifecycleMappingMetadata.lifecycleMappingId==null, convert to error lifecycle mapping metadata
+
result.setLifecycleMappingMetadata(lifecycleMappingMetadata);
//
@@ -336,6 +341,9 @@ public class LifecycleMappingFactory {
}
}
}
+
+ // TODO valid executionMetadatas and convert to error mapping invalid enties.
+
executionMapping.put(executionKey, executionMetadatas);
}
} else {
@@ -504,7 +512,7 @@ public class LifecycleMappingFactory {
sources.add(referencedSource);
}
- MavenExecutionRequest request = newMavenExecutionRequest(templateRequest);
+ MavenExecutionRequest request = newMavenExecutionRequest(templateRequest);
project = maven.resolveParentProject(request, project, monitor);
} while(project != null);
@@ -592,7 +600,9 @@ public class LifecycleMappingFactory {
return new MojoExecutionBuildParticipant(mojoExecution, runOnIncremental);
}
- private static AbstractLifecycleMapping getLifecycleMapping(String mappingId) {
+ public static Map<String, IConfigurationElement> getLifecycleMappingExtensions() {
+ Map<String, IConfigurationElement> mappings = new HashMap<String, IConfigurationElement>(); // not ordered
+
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint configuratorsExtensionPoint = registry.getExtensionPoint(EXTENSION_LIFECYCLE_MAPPINGS);
if(configuratorsExtensionPoint != null) {
@@ -601,12 +611,22 @@ public class LifecycleMappingFactory {
IConfigurationElement[] elements = extension.getConfigurationElements();
for(IConfigurationElement element : elements) {
if(element.getName().equals(ELEMENT_LIFECYCLE_MAPPING)) {
- if(mappingId.equals(element.getAttribute(ATTR_ID)))
- return createLifecycleMapping(element);
+ mappings.put(element.getAttribute(ATTR_ID), element);
}
}
}
}
+
+ return mappings;
+ }
+
+ private static AbstractLifecycleMapping getLifecycleMapping(String mappingId) {
+ IConfigurationElement element = getLifecycleMappingExtensions().get(mappingId);
+ if(element != null && element.getName().equals(ELEMENT_LIFECYCLE_MAPPING)) {
+ if(mappingId.equals(element.getAttribute(ATTR_ID))) {
+ return createLifecycleMapping(element);
+ }
+ }
return null;
}
@@ -630,8 +650,13 @@ public class LifecycleMappingFactory {
return null;
}
- private static IConfigurationElement getProjectConfiguratorExtension(String configuratorId) {
+ public static Map<String, IConfigurationElement> getProjectConfiguratorExtensions() {
IExtensionRegistry registry = Platform.getExtensionRegistry();
+ return getProjectConfiguratorExtensions(registry);
+ }
+
+ public static Map<String, IConfigurationElement> getProjectConfiguratorExtensions(IExtensionRegistry registry) {
+ Map<String, IConfigurationElement> extensions = new HashMap<String, IConfigurationElement>();
IExtensionPoint configuratorsExtensionPoint = registry.getExtensionPoint(EXTENSION_PROJECT_CONFIGURATORS);
if(configuratorsExtensionPoint != null) {
IExtension[] configuratorExtensions = configuratorsExtensionPoint.getExtensions();
@@ -639,13 +664,21 @@ public class LifecycleMappingFactory {
IConfigurationElement[] elements = extension.getConfigurationElements();
for(IConfigurationElement element : elements) {
if(element.getName().equals(ELEMENT_CONFIGURATOR)) {
- if(configuratorId.equals(element.getAttribute(AbstractProjectConfigurator.ATTR_ID))) {
- return element;
- }
+ extensions.put(element.getAttribute(AbstractProjectConfigurator.ATTR_ID), element);
}
}
}
}
+ return extensions;
+ }
+
+ private static IConfigurationElement getProjectConfiguratorExtension(String configuratorId) {
+ IConfigurationElement element = getProjectConfiguratorExtensions().get(configuratorId);
+ if(element != null && element.getName().equals(ELEMENT_CONFIGURATOR)) {
+ if(configuratorId.equals(element.getAttribute(AbstractProjectConfigurator.ATTR_ID))) {
+ return element;
+ }
+ }
return null;
}
@@ -869,7 +902,7 @@ public class LifecycleMappingFactory {
/**
* Returns lifecycle mapping metadata sources provided by all installed bundles
*/
- private static List<LifecycleMappingMetadataSource> getBundleMetadataSources() {
+ public static List<LifecycleMappingMetadataSource> getBundleMetadataSources() {
// XXX cache!
ArrayList<LifecycleMappingMetadataSource> sources = new ArrayList<LifecycleMappingMetadataSource>();
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/ILifecycleMappingElementKey.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/ILifecycleMappingElement.java
index 9c2fa642..bcd03ba6 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/ILifecycleMappingElementKey.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/ILifecycleMappingElement.java
@@ -14,7 +14,10 @@ package org.eclipse.m2e.core.internal.lifecyclemapping.discovery;
/**
* Identifies Maven project elements that can have lifecycle mapping configuration. Currently, these are project
* packaging types and maven plugin executions. Implementations must provide #hashCode() and #equals(Object) methods.
+ * Instances of the same element referenced from different projects are expected to be equal.
*/
-public interface ILifecycleMappingElementKey {
+public interface ILifecycleMappingElement {
+
+ public ILifecycleMappingRequirement getLifecycleMappingRequirement();
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/ILifecycleMappingRequirement.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/ILifecycleMappingRequirement.java
new file mode 100644
index 00000000..8aacf39b
--- /dev/null
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/ILifecycleMappingRequirement.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Sonatype, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.m2e.core.internal.lifecyclemapping.discovery;
+
+/**
+ * Represents lifecycle mapping requirement, i.e.
+ * <ul>
+ * <li>Mapping for packaging type</li>
+ * <li>lifecycleMapping extension</li>
+ * <li>Mapping for maven plugin execution</li>
+ * <li>projectConfigurator extension</li>
+ * </ul>
+ */
+public interface ILifecycleMappingRequirement {
+
+}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/IMavenDiscovery.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/IMavenDiscovery.java
index dc75d4f6..ce6280b3 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/IMavenDiscovery.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/IMavenDiscovery.java
@@ -35,7 +35,7 @@ public interface IMavenDiscovery {
* with already installed Eclipse bundles and preselected proposals.
* </p>
*/
- public Map<ILifecycleMappingElementKey, List<IMavenDiscoveryProposal>> discover(MavenProject mavenProject,
+ public Map<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>> discover(MavenProject mavenProject,
List<MojoExecution> mojoExecutions, List<IMavenDiscoveryProposal> preselected, IProgressMonitor monitor)
throws CoreException;
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/LifecycleMappingConfiguration.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/LifecycleMappingConfiguration.java
index 933d08b4..3fde19eb 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/lifecyclemapping/LifecycleMappingConfiguration.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/LifecycleMappingConfiguration.java
@@ -6,19 +6,26 @@
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package org.eclipse.m2e.core.ui.internal.lifecyclemapping;
+package org.eclipse.m2e.core.internal.lifecyclemapping.discovery;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.osgi.util.NLS;
+
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.execution.MavenSession;
@@ -26,20 +33,14 @@ import org.apache.maven.lifecycle.MavenExecutionPlan;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.project.MavenProject;
import org.apache.maven.properties.internal.EnvironmentUtils;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.SubMonitor;
+
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.IMaven;
import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingConfigurationException;
import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory;
import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingResult;
-import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingElementKey;
-import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.IMavenDiscoveryProposal;
-import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.MojoExecutionMappingConfiguration;
-import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.PackagingTypeMappingConfiguration;
-import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ProjectLifecycleMappingConfiguration;
+import org.eclipse.m2e.core.internal.lifecyclemapping.MappingMetadataSource;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.PackagingTypeMappingConfiguration.PackagingTypeMappingRequirement;
import org.eclipse.m2e.core.internal.lifecyclemapping.model.PluginExecutionAction;
import org.eclipse.m2e.core.internal.lifecyclemapping.model.PluginExecutionMetadata;
import org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager;
@@ -47,42 +48,58 @@ import org.eclipse.m2e.core.project.MavenProjectInfo;
import org.eclipse.m2e.core.project.ProjectImportConfiguration;
import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
-import org.eclipse.osgi.util.NLS;
-/**
- * @TODO I don't like this code in UI, but I don't see a nice way to move it to the backend
- * @author igor
- */
-@SuppressWarnings("restriction")
public class LifecycleMappingConfiguration {
- private final Map<MavenProjectInfo, ProjectLifecycleMappingConfiguration> projects = new HashMap<MavenProjectInfo, ProjectLifecycleMappingConfiguration>();
+ private final Map<MavenProjectInfo, ProjectLifecycleMappingConfiguration> allprojects = new HashMap<MavenProjectInfo, ProjectLifecycleMappingConfiguration>();
- private Map<ILifecycleMappingElementKey, List<IMavenDiscoveryProposal>> allproposals;
+ /**
+ * All proposals to satisfy mapping requirements
+ */
+ private Map<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>> allproposals;
+ /**
+ * Mapping proposals selected for implementation, i.e. bundles to be installed and mojo executions to be ignored.
+ */
private final Set<IMavenDiscoveryProposal> selectedProposals = new LinkedHashSet<IMavenDiscoveryProposal>();
+ /**
+ * Mapping requirements satisfied by installed eclipse bundles and m2e default lifecycle mapping metadata.
+ */
+ private final Set<ILifecycleMappingRequirement> installedProviders = new HashSet<ILifecycleMappingRequirement>();
+
+ /**
+ * Selected projects. null means "nothing is selected".
+ */
+ private Set<MavenProjectInfo> selectedProjects;
+
private LifecycleMappingConfiguration() {
}
public List<ProjectLifecycleMappingConfiguration> getProjects() {
- return new ArrayList<ProjectLifecycleMappingConfiguration>(projects.values());
+ ArrayList<ProjectLifecycleMappingConfiguration> projects = new ArrayList<ProjectLifecycleMappingConfiguration>();
+ for(Map.Entry<MavenProjectInfo, ProjectLifecycleMappingConfiguration> project : allprojects.entrySet()) {
+ if(selectedProjects.contains(project.getKey())) {
+ projects.add(project.getValue());
+ }
+ }
+ return projects;
}
private void addProject(MavenProjectInfo info, ProjectLifecycleMappingConfiguration project) {
- this.projects.put(info, project);
+ this.allprojects.put(info, project);
}
- public void setProposals(Map<ILifecycleMappingElementKey, List<IMavenDiscoveryProposal>> proposals) {
+ public void setProposals(Map<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>> proposals) {
this.allproposals = proposals;
}
/**
* Returns all proposals available for provided requirement or empty List.
*/
- public List<IMavenDiscoveryProposal> getProposals(ILifecycleMappingElementKey requirement) {
- if(allproposals == null) {
+ public List<IMavenDiscoveryProposal> getProposals(ILifecycleMappingRequirement requirement) {
+ if(allproposals == null || requirement == null) {
return Collections.emptyList();
}
List<IMavenDiscoveryProposal> result = allproposals.get(requirement);
@@ -92,6 +109,13 @@ public class LifecycleMappingConfiguration {
return result;
}
+ public Map<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>> getAllProposals() {
+ if (allproposals==null) {
+ return Collections.emptyMap();
+ }
+ return allproposals;
+ }
+
public void addSelectedProposal(IMavenDiscoveryProposal proposal) {
selectedProposals.add(proposal);
}
@@ -100,25 +124,62 @@ public class LifecycleMappingConfiguration {
selectedProposals.remove(proposal);
}
+ public boolean isRequirementSatisfied(ILifecycleMappingRequirement requirement) {
+ return isRequirementSatisfied(requirement, false);
+ }
+
+ public boolean isRequirementSatisfied(ILifecycleMappingRequirement requirement, boolean installedOnly) {
+ if(requirement == null) {
+ return true;
+ }
+
+ if(installedProviders.contains(requirement)) {
+ return true;
+ }
+
+ if(installedOnly || allproposals == null) {
+ return false;
+ }
+
+ List<IMavenDiscoveryProposal> proposals = allproposals.get(requirement);
+ if(proposals != null) {
+ for(IMavenDiscoveryProposal proposal : proposals) {
+ if(selectedProposals.contains(proposal)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
/**
* Returns true if mapping configuration is complete after applying selected proposals.
*/
public boolean isMappingComplete() {
- for(ProjectLifecycleMappingConfiguration project : projects.values()) {
- PackagingTypeMappingConfiguration packagingTypeMappingConfiguration = project
- .getPackagingTypeMappingConfiguration();
- if(!packagingTypeMappingConfiguration.isOK()
- && getSelectedProposal(packagingTypeMappingConfiguration.getLifecycleMappingElementKey()) == null) {
+ return isMappingComplete(false);
+ }
+
+ public boolean isMappingComplete(boolean installedOnly) {
+ for(ProjectLifecycleMappingConfiguration project : getProjects()) {
+ ILifecycleMappingRequirement packagingRequirement = project.getPackagingTypeMappingConfiguration()
+ .getLifecycleMappingRequirement();
+
+ if(!(packagingRequirement instanceof PackagingTypeMappingRequirement)
+ && !isRequirementSatisfied(packagingRequirement, installedOnly)) {
return false;
}
for(MojoExecutionMappingConfiguration mojoExecutionConfiguration : project.getMojoExecutionConfigurations()) {
- if(!mojoExecutionConfiguration.isOK()
- && getSelectedProposal(mojoExecutionConfiguration.getLifecycleMappingElementKey()) == null) {
+ ILifecycleMappingRequirement executionRequirement = mojoExecutionConfiguration.getLifecycleMappingRequirement();
+ if(!isRequirementSatisfied(executionRequirement, installedOnly)
+ && LifecycleMappingFactory.isInterestingPhase(mojoExecutionConfiguration.getMojoExecutionKey()
+ .getLifecyclePhase())) {
return false;
}
}
}
+
return true;
}
@@ -126,35 +187,36 @@ public class LifecycleMappingConfiguration {
* Automatically selects proposals when where is only one possible solution to a problem. Returns true if mapping
* configuration is complete after applying automatically selected proposals.
*/
- public boolean autoCompleteMapping() {
- LinkedHashSet<ILifecycleMappingElementKey> elements = new LinkedHashSet<ILifecycleMappingElementKey>();
+ public void autoCompleteMapping() {
+ LinkedHashSet<ILifecycleMappingRequirement> requirements = new LinkedHashSet<ILifecycleMappingRequirement>();
- for(ProjectLifecycleMappingConfiguration project : projects.values()) {
- PackagingTypeMappingConfiguration packagingTypeMappingConfiguration = project
- .getPackagingTypeMappingConfiguration();
+ for(ProjectLifecycleMappingConfiguration project : getProjects()) {
+ ILifecycleMappingRequirement packagingRequirement = project.getPackagingTypeMappingConfiguration()
+ .getLifecycleMappingRequirement();
- if(!packagingTypeMappingConfiguration.isOK()) {
- elements.add(packagingTypeMappingConfiguration.getLifecycleMappingElementKey());
+ if(packagingRequirement != null) {
+ requirements.add(packagingRequirement);
}
for(MojoExecutionMappingConfiguration mojoExecutionConfiguration : project.getMojoExecutionConfigurations()) {
- if(!mojoExecutionConfiguration.isOK()) {
- elements.add(mojoExecutionConfiguration.getLifecycleMappingElementKey());
+ ILifecycleMappingRequirement executionRequirement = mojoExecutionConfiguration.getLifecycleMappingRequirement();
+ if(executionRequirement != null) {
+ requirements.add(executionRequirement);
}
}
}
- for(ILifecycleMappingElementKey element : elements) {
- List<IMavenDiscoveryProposal> proposals = getProposals(element);
- if(proposals.size() == 1) {
- addSelectedProposal(proposals.get(0));
+ for(ILifecycleMappingRequirement requirement : requirements) {
+ if(!installedProviders.contains(requirement)) {
+ List<IMavenDiscoveryProposal> proposals = getProposals(requirement);
+ if(proposals.size() == 1) {
+ addSelectedProposal(proposals.get(0));
+ }
}
}
-
- return isMappingComplete();
}
- public IMavenDiscoveryProposal getSelectedProposal(ILifecycleMappingElementKey mojoExecutionKey) {
+ public IMavenDiscoveryProposal getSelectedProposal(ILifecycleMappingRequirement mojoExecutionKey) {
if(allproposals == null) {
return null;
}
@@ -177,26 +239,17 @@ public class LifecycleMappingConfiguration {
public void clearSelectedProposals() {
selectedProposals.clear();
}
-
- public static LifecycleMappingConfiguration clone(LifecycleMappingConfiguration original, Collection<MavenProjectInfo> filter) {
- if (original == null) {
- throw new IllegalArgumentException("The original LifecycleMappingConfiguration shall not be null.");
- }
- LifecycleMappingConfiguration result = new LifecycleMappingConfiguration();
- for (MavenProjectInfo info : filter) {
- ProjectLifecycleMappingConfiguration res = original.projects.get(info);
- if (res != null) {
- result.addProject(info, res);
- }
- }
- return result;
- }
+ /**
+ * Calculates lifecycle mapping configuration of the specified projects. Only considers mapping metadata specified in
+ * projects' pom.xml files and their parent pom.xml files. Does NOT consider mapping metadata available from installed
+ * Eclipse plugins and m2e default lifecycle mapping metadata.
+ */
public static LifecycleMappingConfiguration calculate(Collection<MavenProjectInfo> projects,
ProjectImportConfiguration importConfiguration, IProgressMonitor monitor) throws CoreException {
monitor.beginTask("Analysing project execution plan", projects.size());
-
+
LifecycleMappingConfiguration result = new LifecycleMappingConfiguration();
MavenPlugin mavenPlugin = MavenPlugin.getDefault();
@@ -241,8 +294,19 @@ public class LifecycleMappingConfiguration {
mojoExecutions.addAll(executionPlan.getMojoExecutions());
LifecycleMappingResult lifecycleResult = new LifecycleMappingResult();
- LifecycleMappingFactory.calculateEffectiveLifecycleMappingMetadata(lifecycleResult, request, mavenProject,
- mojoExecutions, subMmonitor);
+
+ List<MappingMetadataSource> metadataSources;
+ try {
+ metadataSources = LifecycleMappingFactory.getProjectMetadataSources(request, mavenProject,
+ LifecycleMappingFactory.getBundleMetadataSources(), monitor);
+ } catch(LifecycleMappingConfigurationException e) {
+ // could not read/parse/interpret mapping metadata configured in the pom or inherited from parent pom.
+ // record the problem and return
+ continue;
+ }
+
+ LifecycleMappingFactory.calculateEffectiveLifecycleMappingMetadata(lifecycleResult, request, metadataSources,
+ mavenProject, mojoExecutions, false);
LifecycleMappingFactory.instantiateLifecycleMapping(lifecycleResult, mavenProject,
lifecycleResult.getLifecycleMappingId());
LifecycleMappingFactory.instantiateProjectConfigurators(mavenProject, lifecycleResult,
@@ -250,32 +314,58 @@ public class LifecycleMappingConfiguration {
ProjectLifecycleMappingConfiguration configuration = new ProjectLifecycleMappingConfiguration(
projectInfo.getLabel(), mavenProject, mojoExecutions, new PackagingTypeMappingConfiguration(
- mavenProject.getPackaging(), lifecycleResult.getLifecycleMappingId(),
- lifecycleResult.getLifecycleMapping()));
+ mavenProject.getPackaging(), lifecycleResult.getLifecycleMappingId()));
+
+ if(lifecycleResult.getLifecycleMapping() != null) {
+ result.addInstalledProvider(configuration.getPackagingTypeMappingConfiguration()
+ .getLifecycleMappingRequirement());
+ }
for(Map.Entry<MojoExecutionKey, List<PluginExecutionMetadata>> entry : lifecycleResult
.getMojoExecutionMapping().entrySet()) {
MojoExecutionKey key = entry.getKey();
- MojoExecutionMappingConfiguration mojoExecutionConfiguration = new MojoExecutionMappingConfiguration(key);
- for(PluginExecutionMetadata pluginExecutionMetadata : entry.getValue()) {
- AbstractProjectConfigurator configurator = null;
- if(pluginExecutionMetadata.getAction() == PluginExecutionAction.configurator) {
- try {
- configurator = lifecycleResult.getProjectConfigurators().get(
- LifecycleMappingFactory.getProjectConfiguratorId(pluginExecutionMetadata));
- } catch(LifecycleMappingConfigurationException e) {
- // TODO what do I do with this?
- }
+ List<PluginExecutionMetadata> mapppings = entry.getValue();
+ PluginExecutionMetadata primaryMapping = null;
+ if(mapppings != null && !mapppings.isEmpty()) {
+ primaryMapping = mapppings.get(0);
+ }
+ MojoExecutionMappingConfiguration executionConfiguration = new MojoExecutionMappingConfiguration(key,
+ primaryMapping);
+ configuration.addMojoExecution(executionConfiguration);
+ if(primaryMapping != null && primaryMapping.getAction() == PluginExecutionAction.configurator) {
+ AbstractProjectConfigurator projectConfigurator = lifecycleResult.getProjectConfigurators().get(
+ LifecycleMappingFactory.getProjectConfiguratorId(primaryMapping));
+ if(projectConfigurator != null) {
+ result.addInstalledProvider(executionConfiguration.getLifecycleMappingRequirement());
}
- mojoExecutionConfiguration.addMapping(pluginExecutionMetadata, configurator);
}
- configuration.addMojoExecution(mojoExecutionConfiguration);
}
result.addProject(projectInfo, configuration);
}
}
+ result.setSelectedProjects(projects);
+
return result;
}
+ private void addInstalledProvider(ILifecycleMappingRequirement requirement) {
+ installedProviders.add(requirement);
+ }
+
+ public List<ProjectLifecycleMappingConfiguration> getProjects(ILifecycleMappingElement configurationElement) {
+ List<ProjectLifecycleMappingConfiguration> result = new ArrayList<ProjectLifecycleMappingConfiguration>();
+ for(ProjectLifecycleMappingConfiguration project : getProjects()) {
+ if(project.getMojoExecutionConfigurations().equals(configurationElement)
+ || project.getMojoExecutionConfigurations().contains(configurationElement)) {
+ result.add(project);
+ }
+ }
+ return result;
+ }
+
+ public void setSelectedProjects(Collection<MavenProjectInfo> projects) {
+ this.selectedProjects = new HashSet<MavenProjectInfo>(projects);
+ }
+
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/MojoExecutionMappingConfiguration.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/MojoExecutionMappingConfiguration.java
index 227b4847..143ad68a 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/MojoExecutionMappingConfiguration.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/MojoExecutionMappingConfiguration.java
@@ -8,74 +8,103 @@
package org.eclipse.m2e.core.internal.lifecyclemapping.discovery;
-import java.util.ArrayList;
-import java.util.List;
-
import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory;
import org.eclipse.m2e.core.internal.lifecyclemapping.model.PluginExecutionAction;
import org.eclipse.m2e.core.internal.lifecyclemapping.model.PluginExecutionMetadata;
-import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
/**
- * MojoExecutionMappingConfiguration
- *
- * @author igor
+ * Represents Maven plugin execution bound to project lifecycle and corresponding lifecycle mapping metadata. Only
+ * considers primary mapping, secondary project configurators are ignored.
*/
-public class MojoExecutionMappingConfiguration {
+public class MojoExecutionMappingConfiguration implements ILifecycleMappingElement {
- public static class MojoExecutionMappingInfo {
- private final PluginExecutionMetadata mapping;
+ public static class MojoExecutionMappingRequirement implements ILifecycleMappingRequirement {
+ private final MojoExecutionKey execution;
- private final AbstractProjectConfigurator configurator;
+ public MojoExecutionMappingRequirement(MojoExecutionKey execution) {
+ this.execution = new MojoExecutionKey(execution.getGroupId(), execution.getArtifactId(), execution.getVersion(),
+ execution.getGoal(), null, null);
+ }
- public MojoExecutionMappingInfo(PluginExecutionMetadata mapping, AbstractProjectConfigurator configurator) {
- this.mapping = mapping;
- this.configurator = configurator;
+ public int hashCode() {
+ return execution.hashCode();
}
- public PluginExecutionMetadata getMapping() {
- return mapping;
+ public boolean equals(Object obj) {
+ if(this == obj) {
+ return true;
+ }
+
+ if(!(obj instanceof MojoExecutionMappingRequirement)) {
+ return false;
+ }
+
+ MojoExecutionMappingRequirement other = (MojoExecutionMappingRequirement) obj;
+
+ return execution.equals(other.execution);
}
- public AbstractProjectConfigurator getConfigurator() {
- return configurator;
+ public MojoExecutionKey getExecution() {
+ return execution;
}
}
- public static class Key implements ILifecycleMappingElementKey {
- private final MojoExecutionKey execution;
+ public static class ProjectConfiguratorMappingRequirement implements ILifecycleMappingRequirement {
+ private final MojoExecutionKey execution; // only to make AggregateMappingLabelProvider happy. not part of the key
+
+ private final String configuratorId;
- public Key(MojoExecutionKey execution) {
+ public ProjectConfiguratorMappingRequirement(MojoExecutionKey execution, String configuratorId) {
this.execution = execution;
+ this.configuratorId = configuratorId;
}
public int hashCode() {
- return execution.hashCode();
+ return configuratorId.hashCode();
}
public boolean equals(Object obj) {
- if(obj == this) {
+ if(this == obj) {
return true;
}
- if(!(obj instanceof Key)) {
+
+ if(!(obj instanceof ProjectConfiguratorMappingRequirement)) {
return false;
}
- return execution.equals(((Key) obj).execution);
+
+ ProjectConfiguratorMappingRequirement other = (ProjectConfiguratorMappingRequirement) obj;
+
+ return configuratorId.equals(other.configuratorId);
}
public MojoExecutionKey getExecution() {
return execution;
}
+
+ public String getProjectConfiguratorId() {
+ return configuratorId;
+ }
}
private final MojoExecutionKey execution;
- private final List<MojoExecutionMappingInfo> mappings = new ArrayList<MojoExecutionMappingInfo>();
+ private final PluginExecutionMetadata mapping;
+
+ private final ILifecycleMappingRequirement requirement;
- public MojoExecutionMappingConfiguration(MojoExecutionKey execution) {
+ public MojoExecutionMappingConfiguration(MojoExecutionKey execution, PluginExecutionMetadata mapping) {
this.execution = execution;
+ this.mapping = mapping;
+
+ if(mapping == null) {
+ requirement = new MojoExecutionMappingRequirement(execution);
+ } else if(mapping.getAction() == PluginExecutionAction.configurator) {
+ requirement = new ProjectConfiguratorMappingRequirement(execution, LifecycleMappingFactory.getProjectConfiguratorId(mapping));
+ } else {
+ requirement = null; // this execution is fully mapped with <execute/>, <ignore/> or <error/> action
+ }
}
public String getArtifactId() {
@@ -98,35 +127,72 @@ public class MojoExecutionMappingConfiguration {
return execution;
}
- public boolean isOK() {
- if(mappings == null || mappings.isEmpty()) {
- // TODO not sure I like this here
- return !LifecycleMappingFactory.isInterestingPhase(execution.getLifecyclePhase());
- }
- for(MojoExecutionMappingInfo info : mappings) {
- if(info.getMapping().getAction() == PluginExecutionAction.error) {
- return false;
- }
- if(info.getMapping().getAction() == PluginExecutionAction.configurator && info.getConfigurator() == null) {
- return false;
- }
- }
- return true;
- }
-
public MojoExecutionKey getExecution() {
return this.execution;
}
-
- public List<MojoExecutionMappingInfo> getMappings() {
- return this.mappings;
+
+ public PluginExecutionMetadata getMapping() {
+ return this.mapping;
+ }
+
+ /**
+ * Mapping requirement key. Null if this mojo execution configuration is complete, i.e. mapped to ignore, execute or
+ * error actions.
+ */
+ public ILifecycleMappingRequirement getLifecycleMappingRequirement() {
+ return requirement;
}
- public void addMapping(PluginExecutionMetadata pluginExecutionMetadata, AbstractProjectConfigurator configurator) {
- mappings.add(new MojoExecutionMappingInfo(pluginExecutionMetadata, configurator));
+ public int hashCode() {
+ int hash = execution.hashCode();
+
+ if(mapping != null) {
+ hash = 17 * hash + mapping.getAction().hashCode();
+ if(mapping.getAction() == PluginExecutionAction.configurator) {
+ hash += LifecycleMappingFactory.getProjectConfiguratorId(mapping).hashCode();
+ }
+ }
+
+ return hash;
+ }
+
+ public boolean equals(Object obj) {
+ if(this == obj) {
+ return true;
+ }
+ if(!(obj instanceof MojoExecutionMappingConfiguration)) {
+ return false;
+ }
+ MojoExecutionMappingConfiguration other = (MojoExecutionMappingConfiguration) obj;
+
+ if(!execution.equals(other.execution)) {
+ return false;
+ }
+
+ if(mapping == null) {
+ return other.mapping == null;
+ }
+
+ if(other.mapping == null) {
+ return false;
+ }
+
+ if(mapping.getAction() != other.mapping.getAction()) {
+ return false;
+ }
+
+ if(mapping.getAction() == PluginExecutionAction.configurator) {
+ String configuratorId = LifecycleMappingFactory.getProjectConfiguratorId(mapping);
+ String otherConfiguratorId = LifecycleMappingFactory.getProjectConfiguratorId(other.mapping);
+ if(!eq(configuratorId, otherConfiguratorId)) {
+ return false;
+ }
+ }
+
+ return true;
}
- public ILifecycleMappingElementKey getLifecycleMappingElementKey() {
- return new Key(execution);
+ private static <T> boolean eq(T a, T b) {
+ return a != null ? a.equals(b) : b == null;
}
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/PackagingTypeMappingConfiguration.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/PackagingTypeMappingConfiguration.java
index 115abbf6..2fe25232 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/PackagingTypeMappingConfiguration.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/discovery/PackagingTypeMappingConfiguration.java
@@ -11,20 +11,15 @@
package org.eclipse.m2e.core.internal.lifecyclemapping.discovery;
-import org.eclipse.m2e.core.project.configurator.ILifecycleMapping;
-
-
/**
- * PackagingTypeMappingConfiguration
- *
- * @author igor
+ * Represents project packaging type and corresponding lifecycle mapping metadata.
*/
-public class PackagingTypeMappingConfiguration {
+public class PackagingTypeMappingConfiguration implements ILifecycleMappingElement {
- public static class Key implements ILifecycleMappingElementKey {
- private final String packaging;
+ public static class PackagingTypeMappingRequirement implements ILifecycleMappingRequirement {
+ private String packaging;
- public Key(String packaging) {
+ public PackagingTypeMappingRequirement(String packaging) {
this.packaging = packaging;
}
@@ -33,32 +28,76 @@ public class PackagingTypeMappingConfiguration {
}
public boolean equals(Object obj) {
- if(obj == this) {
+ if(this == obj) {
return true;
}
- if(!(obj instanceof Key)) {
+
+ if(!(obj instanceof PackagingTypeMappingRequirement)) {
return false;
}
- return packaging.equals(((Key) obj).packaging);
+
+ PackagingTypeMappingRequirement other = (PackagingTypeMappingRequirement) obj;
+
+ return packaging.equals(other.packaging);
}
public String getPackaging() {
return packaging;
}
+ }
+
+ public static class LifecycleStrategyMappingRequirement implements ILifecycleMappingRequirement {
+ private final String packaging;
+
+ private final String lifecycleMappingId;
+
+ public LifecycleStrategyMappingRequirement(String packaging, String lifecycleMappingId) {
+ this.packaging = packaging;
+ this.lifecycleMappingId = lifecycleMappingId;
+ }
+
+ public int hashCode() {
+ return lifecycleMappingId.hashCode();
+ }
+ public boolean equals(Object obj) {
+ if(this == obj) {
+ return true;
+ }
+
+ if(!(obj instanceof LifecycleStrategyMappingRequirement)) {
+ return false;
+ }
+
+ LifecycleStrategyMappingRequirement other = (LifecycleStrategyMappingRequirement) obj;
+
+ return lifecycleMappingId.equals(other.lifecycleMappingId);
+ }
+
+ public String getLifecycleMappingId() {
+ return lifecycleMappingId;
+ }
+
+ public String getPackaging() {
+ return packaging;
+ }
}
private final String packaging;
private final String lifecycleMappingId;
- private final ILifecycleMapping lifecycleMapping;
+ private final ILifecycleMappingRequirement requirement;
- public PackagingTypeMappingConfiguration(String packaging, String lifecycleMappingId,
- ILifecycleMapping lifecycleMapping) {
+ public PackagingTypeMappingConfiguration(String packaging, String lifecycleMappingId) {
this.packaging = packaging;
this.lifecycleMappingId = lifecycleMappingId;
- this.lifecycleMapping = lifecycleMapping;
+
+ if(lifecycleMappingId == null) {
+ requirement = new PackagingTypeMappingRequirement(packaging);
+ } else {
+ requirement = new LifecycleStrategyMappingRequirement(packaging, lifecycleMappingId);
+ }
}
public String getPackaging() {
@@ -69,16 +108,32 @@ public class PackagingTypeMappingConfiguration {
return lifecycleMappingId;
}
- public ILifecycleMapping getLifecycleMapping() {
- return lifecycleMapping;
+ public int hashCode() {
+ int hash = packaging.hashCode();
+ hash = 17 * hash + (lifecycleMappingId != null ? lifecycleMappingId.hashCode() : 0);
+ return hash;
+ }
+
+ public boolean equals(Object obj) {
+ if(this == obj) {
+ return true;
+ }
+
+ if(!(obj instanceof PackagingTypeMappingConfiguration)) {
+ return false;
+ }
+
+ PackagingTypeMappingConfiguration other = (PackagingTypeMappingConfiguration) obj;
+
+ return packaging.equals(other.packaging) && eq(lifecycleMappingId, other.lifecycleMappingId);
}
- public boolean isOK() {
- return lifecycleMappingId != null && lifecycleMapping != null;
+ private static <T> boolean eq(T a, T b) {
+ return a != null ? a.equals(b) : b == null;
}
- public ILifecycleMappingElementKey getLifecycleMappingElementKey() {
- return new Key(packaging);
+ public ILifecycleMappingRequirement getLifecycleMappingRequirement() {
+ return requirement;
}
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/MojoExecutionKey.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/MojoExecutionKey.java
index 8e8316e3..188206c2 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/MojoExecutionKey.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/MojoExecutionKey.java
@@ -55,9 +55,9 @@ public class MojoExecutionKey implements Serializable {
int hash = groupId.hashCode();
hash = 17 * hash + artifactId.hashCode();
hash = 17 * hash + version.hashCode();
- hash = 17 * goal.hashCode();
- hash = 17 * executionId.hashCode();
- hash = 17 * lifecyclePhase.hashCode();
+ hash = 17 * hash + goal.hashCode();
+ hash = 17 * hash + (executionId != null ? executionId.hashCode() : 0);
+ hash = 17 * hash + (lifecyclePhase != null ? lifecyclePhase.hashCode() : 0);
return hash;
}
@@ -71,9 +71,8 @@ public class MojoExecutionKey implements Serializable {
MojoExecutionKey other = (MojoExecutionKey) obj;
- return groupId.equals(other.groupId) && artifactId.equals(other.artifactId) && version.equals(other.version)
- && goal.equals(other.goal) && executionId.equals(other.executionId)
- && lifecyclePhase.equals(other.lifecyclePhase);
+ return eq(groupId, other.groupId) && eq(artifactId, other.artifactId) && eq(version, other.version)
+ && eq(goal, other.goal) && eq(executionId, other.executionId) && eq(lifecyclePhase, other.lifecyclePhase);
}
public String getGroupId() {
@@ -117,4 +116,8 @@ public class MojoExecutionKey implements Serializable {
&& version.equals(mojoExecution.getVersion()) && goal.equals(mojoExecution.getGoal())
&& executionId.equals(mojoExecution.getExecutionId());
}
+
+ private static <T> boolean eq(T a, T b) {
+ return a != null ? a.equals(b) : b == null;
+ }
}
diff --git a/org.eclipse.m2e.discovery-directory/org.eclipse.m2e.discovery.oss/lifecycle/org.eclipse.m2e.discovery.lifecyclemapping.plexus-annotations.pluginxml b/org.eclipse.m2e.discovery-directory/org.eclipse.m2e.discovery.oss/lifecycle/org.eclipse.m2e.discovery.lifecyclemapping.plexus-annotations.pluginxml
new file mode 100644
index 00000000..57e3a395
--- /dev/null
+++ b/org.eclipse.m2e.discovery-directory/org.eclipse.m2e.discovery.oss/lifecycle/org.eclipse.m2e.discovery.lifecyclemapping.plexus-annotations.pluginxml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.m2e.core.projectConfigurators">
+ <configurator
+ class="org.sonatype.m2e.plexus.annotations.internal.PlexusProjectConfigurator"
+ id="org.sonatype.m2e.plexus.annotations.plexusConfigurator"
+ name="Plexus Metadata Generation">
+ </configurator>
+ </extension>
+ <extension
+ point="org.eclipse.m2e.core.lifecycleMappingMetadataSource">
+ </extension>
+</plugin>
diff --git a/org.eclipse.m2e.discovery-directory/org.eclipse.m2e.discovery.oss/lifecycle/org.eclipse.m2e.discovery.lifecyclemapping.temporary-mojos.pluginxml b/org.eclipse.m2e.discovery-directory/org.eclipse.m2e.discovery.oss/lifecycle/org.eclipse.m2e.discovery.lifecyclemapping.temporary-mojos.pluginxml
new file mode 100644
index 00000000..0e831f3e
--- /dev/null
+++ b/org.eclipse.m2e.discovery-directory/org.eclipse.m2e.discovery.oss/lifecycle/org.eclipse.m2e.discovery.lifecyclemapping.temporary-mojos.pluginxml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.m2e.core.projectConfigurators">
+ <configurator
+ class="org.sonatype.m2e.buildhelper.BuildhelperProjectConfigurator"
+ id="org.sonatype.m2e.buildhelper.buildhelperConfigurator"
+ name="build-helper-maven-plugin">
+ </configurator>
+ <configurator
+ class="org.sonatype.m2e.modello.internal.ModelloProjectConfigurator"
+ id="org.sonatype.m2e.modello.modelloConfigurator"
+ name="Modello Project Configurator">
+ </configurator>
+ <configurator
+ class="org.sonatype.m2e.antlr.internal.AntlrProjectConfigurator"
+ id="org.sonatype.m2e.antlr.antlrConfigurator"
+ name="ANTLR Project Configurator">
+ </configurator>
+ <configurator
+ class="org.sonatype.m2e.pomproperties.internal.PomPropertiesConfigurator"
+ id="org.sonatype.m2e.mavenarchiver.pomProperties"
+ name="MavenArchiver pom.properties Generator">
+ </configurator>
+ </extension>
+ <extension
+ point="org.eclipse.m2e.core.lifecycleMappingMetadataSource">
+ </extension>
+</plugin>
diff --git a/org.eclipse.m2e.discovery-directory/org.eclipse.m2e.discovery.oss/lifecycle/org.eclipse.m2e.discovery.lifecycles.tycho.pluginxml b/org.eclipse.m2e.discovery-directory/org.eclipse.m2e.discovery.oss/lifecycle/org.eclipse.m2e.discovery.lifecycles.tycho.pluginxml
new file mode 100644
index 00000000..c6c8fb60
--- /dev/null
+++ b/org.eclipse.m2e.discovery-directory/org.eclipse.m2e.discovery.oss/lifecycle/org.eclipse.m2e.discovery.lifecycles.tycho.pluginxml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2008 Sonatype, Inc.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+-->
+
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.m2e.core.lifecycleMappings">
+ <lifecycleMapping
+ class="org.sonatype.tycho.m2e.internal.TychoLifecycleMapping"
+ id="org.sonatype.tycho.m2e.tychoLifecycleMapping"
+ name="Tycho Build Lifecycle Mapping">
+ </lifecycleMapping>
+ </extension>
+ <extension
+ point="org.eclipse.m2e.core.projectConfigurators">
+ <configurator
+ class="org.sonatype.tycho.m2e.internal.OsgiBundleProjectConfigurator"
+ id="maven-bundle-plugin"
+ name="Project Configurator for maven-bundle-plugin osgi-bundle projects">
+ </configurator>
+ </extension>
+ <extension
+ point="org.eclipse.m2e.core.lifecycleMappingMetadataSource">
+ </extension>
+</plugin>
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/InstallCatalogItemMappingLabelProvider.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/InstallCatalogItemMappingLabelProvider.java
index bfbc1208..62c82698 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/InstallCatalogItemMappingLabelProvider.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/InstallCatalogItemMappingLabelProvider.java
@@ -9,13 +9,13 @@
package org.eclipse.m2e.internal.discovery;
import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingElementKey;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingRequirement;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.LifecycleMappingConfiguration;
import org.eclipse.m2e.core.ui.internal.lifecyclemapping.ILifecycleMappingLabelProvider;
-import org.eclipse.m2e.core.ui.internal.lifecyclemapping.LifecycleMappingConfiguration;
//TODO : can probably be removed..
@SuppressWarnings({"restriction", "unchecked", "rawtypes"})
-public class InstallCatalogItemMappingLabelProvider implements ILifecycleMappingLabelProvider, IAdapterFactory {
+public class InstallCatalogItemMappingLabelProvider implements IAdapterFactory {
private final InstallCatalogItemMavenDiscoveryProposal proposal;
@@ -34,7 +34,7 @@ public class InstallCatalogItemMappingLabelProvider implements ILifecycleMapping
return ""; //$NON-NLS-1$
}
- public String getEclipseMappingText() {
+ public String getEclipseMappingText(LifecycleMappingConfiguration configuration) {
return "INSTALL " + proposal.getCatalogItem().getName();
}
@@ -51,14 +51,6 @@ public class InstallCatalogItemMappingLabelProvider implements ILifecycleMapping
}
/* (non-Javadoc)
- * @see org.eclipse.m2e.core.ui.internal.lifecyclemapping.ILifecycleMappingLabelProvider#getEclipseMappingText(org.eclipse.m2e.core.ui.internal.lifecyclemapping.LifecycleMappingConfiguration)
- */
- public String getEclipseMappingText(LifecycleMappingConfiguration mappingConfiguration) {
- // TODO Auto-generated method getEclipseMappingText
- return null;
- }
-
- /* (non-Javadoc)
* @see org.eclipse.m2e.core.ui.internal.lifecyclemapping.ILifecycleMappingLabelProvider#isError()
*/
public boolean isError() {
@@ -69,7 +61,7 @@ public class InstallCatalogItemMappingLabelProvider implements ILifecycleMapping
/* (non-Javadoc)
* @see org.eclipse.m2e.core.ui.internal.lifecyclemapping.ILifecycleMappingLabelProvider#getKey()
*/
- public ILifecycleMappingElementKey getKey() {
+ public ILifecycleMappingRequirement getKey() {
// TODO Auto-generated method getKey
return null;
}
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscovery.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscovery.java
index 7f7e30bb..ad477fa3 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscovery.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscovery.java
@@ -12,6 +12,7 @@
package org.eclipse.m2e.internal.discovery;
import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
@@ -20,6 +21,9 @@ import java.util.Collections;
import java.util.List;
import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.eclipse.equinox.internal.p2.discovery.Catalog;
import org.eclipse.equinox.internal.p2.discovery.DiscoveryCore;
import org.eclipse.equinox.internal.p2.discovery.model.CatalogItem;
@@ -30,7 +34,6 @@ import org.eclipse.m2e.core.internal.lifecyclemapping.model.LifecycleMappingMeta
import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
import org.eclipse.m2e.internal.discovery.strategy.M2ERemoteBundleDiscoveryStrategy;
import org.eclipse.m2e.internal.discovery.wizards.MavenCatalogConfiguration;
-import org.eclipse.m2e.internal.discovery.wizards.MavenCatalogViewer;
import org.eclipse.m2e.internal.discovery.wizards.MavenDiscoveryWizard;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
@@ -56,6 +59,12 @@ public class MavenDiscovery {
private static final String PATH = "http://download.eclipse.org/technology/m2e/discovery/directory.xml"; //$NON-NLS-1$
+ public static final String LIFECYCLE_PATH = "lifecycle/"; //$NON-NLS-1$
+
+ public static final String LIFECYCLE_EXT = ".xml"; //$NON-NLS-1$
+
+ public static final String PLUGINXML_EXT = ".pluginxml"; //$NON-NLS-1$
+
public static void launchWizard(Shell shell) {
launchWizard(shell, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
}
@@ -119,7 +128,7 @@ public class MavenDiscovery {
public static LifecycleMappingMetadataSource getLifecycleMappingMetadataSource(CatalogItem ci) {
try {
- URL url = MavenCatalogViewer.getLifecycleMappingMetadataSourceURL(ci);
+ URL url = getLifecycleMappingMetadataSourceURL(ci);
if(url == null) {
return null;
}
@@ -148,4 +157,49 @@ public class MavenDiscovery {
}
return false;
}
+
+ public static void getProvidedProjectConfigurators(CatalogItem ci, List<String> projectConfigurators,
+ List<String> mappingStrategies) {
+ try {
+ URL url = ci.getSource().getResource(LIFECYCLE_PATH + ci.getId() + PLUGINXML_EXT);
+ if(url != null) {
+ InputStream is = url.openStream();
+ parsePluginXml(is, projectConfigurators, mappingStrategies);
+ }
+ } catch(FileNotFoundException e) {
+ log.warn("CatalogItem {} does not contain lifecycle mapping metadata", ci.getId()); //$NON-NLS-1$
+ } catch(Exception e) {
+ log.warn(NLS.bind(Messages.MavenCatalogViewer_Error_loading_lifecycle, ci.getId()), e);
+ }
+ }
+
+ public static void parsePluginXml(InputStream is, List<String> configurators, List<String> mappingStrategies)
+ throws XmlPullParserException, IOException {
+ Xpp3Dom plugin = Xpp3DomBuilder.build(is, "UTF-8"); //$NON-NLS-1$
+ Xpp3Dom[] extensions = plugin.getChildren("extension"); //$NON-NLS-1$
+ for(Xpp3Dom extension : extensions) {
+ String extensionPoint = extension.getAttribute("point"); //$NON-NLS-1$
+ if(LifecycleMappingFactory.EXTENSION_PROJECT_CONFIGURATORS.equals(extensionPoint)) {
+ Xpp3Dom[] configuratorsDom = extension.getChildren("configurator"); //$NON-NLS-1$
+ for(Xpp3Dom configurator : configuratorsDom) {
+ String id = configurator.getAttribute("id"); //$NON-NLS-1$
+ if(id != null) {
+ configurators.add(id);
+ }
+ }
+ } else if (LifecycleMappingFactory.EXTENSION_LIFECYCLE_MAPPINGS.equals(extensionPoint)) {
+ Xpp3Dom[] lifecycleMappingsDom = extension.getChildren("lifecycleMapping"); //$NON-NLS-1$
+ for(Xpp3Dom lifecycleMapping : lifecycleMappingsDom) {
+ String id = lifecycleMapping.getAttribute("id"); //$NON-NLS-1$
+ if(id != null) {
+ mappingStrategies.add(id);
+ }
+ }
+ }
+ }
+ }
+
+ public static URL getLifecycleMappingMetadataSourceURL(CatalogItem ci) {
+ return ci.getSource().getResource(LIFECYCLE_PATH + ci.getId() + LIFECYCLE_EXT);
+ }
}
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java
index 7369c408..e4b457c1 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java
@@ -47,13 +47,14 @@ import org.eclipse.m2e.core.embedder.IMaven;
import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory;
import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingResult;
import org.eclipse.m2e.core.internal.lifecyclemapping.MappingMetadataSource;
-import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingElementKey;
-import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.IMavenDiscoveryProposal;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.ILifecycleMappingRequirement;
import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.IMavenDiscovery;
+import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.IMavenDiscoveryProposal;
import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.MojoExecutionMappingConfiguration;
import org.eclipse.m2e.core.internal.lifecyclemapping.discovery.PackagingTypeMappingConfiguration;
import org.eclipse.m2e.core.internal.lifecyclemapping.model.LifecycleMappingMetadata;
import org.eclipse.m2e.core.internal.lifecyclemapping.model.LifecycleMappingMetadataSource;
+import org.eclipse.m2e.core.internal.lifecyclemapping.model.PluginExecutionAction;
import org.eclipse.m2e.core.internal.lifecyclemapping.model.PluginExecutionMetadata;
import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
import org.eclipse.m2e.core.ui.internal.wizards.IImportWizardPageFactory;
@@ -76,9 +77,16 @@ public class MavenDiscoveryService implements IImportWizardPageFactory, IMavenDi
private final LifecycleMappingMetadataSource metadataSource;
- public CatalogItemCacheEntry(CatalogItem item, LifecycleMappingMetadataSource metadataSource) {
+ private final List<String> projectConfigurators;
+
+ private final List<String> mappingStrategies;
+
+ public CatalogItemCacheEntry(CatalogItem item, LifecycleMappingMetadataSource metadataSource,
+ List<String> projectConfigurators, List<String> mappingStrategies) {
this.item = item;
this.metadataSource = metadataSource;
+ this.projectConfigurators = projectConfigurators;
+ this.mappingStrategies = mappingStrategies;
}
public CatalogItem getItem() {
@@ -88,6 +96,14 @@ public class MavenDiscoveryService implements IImportWizardPageFactory, IMavenDi
public LifecycleMappingMetadataSource getMetadataSource() {
return metadataSource;
}
+
+ public List<String> getProjectConfigurators() {
+ return projectConfigurators;
+ }
+
+ public List<String> getMappingStrategies() {
+ return mappingStrategies;
+ }
}
private List<CatalogItemCacheEntry> items;
@@ -99,7 +115,7 @@ public class MavenDiscoveryService implements IImportWizardPageFactory, IMavenDi
public MavenDiscoveryService(boolean factory) {
}
- public Map<ILifecycleMappingElementKey, List<IMavenDiscoveryProposal>> discover(MavenProject mavenProject,
+ public Map<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>> discover(MavenProject mavenProject,
List<MojoExecution> mojoExecutions, List<IMavenDiscoveryProposal> preselected, IProgressMonitor monitor)
throws CoreException {
@@ -116,13 +132,16 @@ public class MavenDiscoveryService implements IImportWizardPageFactory, IMavenDi
for(CatalogItem item : catalog.getItems()) {
LifecycleMappingMetadataSource metadataSource = MavenDiscovery.getLifecycleMappingMetadataSource(item);
+ List<String> projectConfigurators = new ArrayList<String>();
+ List<String> mappingStrategies = new ArrayList<String>();
+ MavenDiscovery.getProvidedProjectConfigurators(item, projectConfigurators, mappingStrategies);
if(metadataSource != null) {
- addCatalogItem(item, metadataSource);
+ addCatalogItem(item, metadataSource, projectConfigurators, mappingStrategies);
}
}
}
- Map<ILifecycleMappingElementKey, List<IMavenDiscoveryProposal>> proposals = new LinkedHashMap<ILifecycleMappingElementKey, List<IMavenDiscoveryProposal>>();
+ Map<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>> proposals = new LinkedHashMap<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>>();
MavenPlugin mavenPlugin = MavenPlugin.getDefault();
IMaven maven = mavenPlugin.getMaven();
@@ -159,13 +178,22 @@ public class MavenDiscoveryService implements IImportWizardPageFactory, IMavenDi
mavenProject, sources, monitor);
LifecycleMappingFactory.calculateEffectiveLifecycleMappingMetadata(mappingResult, request, metadataSources,
- mavenProject, mojoExecutions);
+ mavenProject, mojoExecutions, false);
LifecycleMappingMetadata lifecycleMappingMetadata = mappingResult.getLifecycleMappingMetadata();
if(lifecycleMappingMetadata != null) {
IMavenDiscoveryProposal proposal = getProposal(lifecycleMappingMetadata.getSource());
if(proposal != null) {
- put(proposals, new PackagingTypeMappingConfiguration.Key(mavenProject.getPackaging()), proposal);
+ put(proposals,
+ new PackagingTypeMappingConfiguration.PackagingTypeMappingRequirement(mavenProject.getPackaging()),
+ proposal);
+ } else if(!LifecycleMappingFactory.getLifecycleMappingExtensions().containsKey(
+ lifecycleMappingMetadata.getLifecycleMappingId())) {
+ if(itemEntry.getMappingStrategies().contains(lifecycleMappingMetadata.getLifecycleMappingId())) {
+ put(proposals, new PackagingTypeMappingConfiguration.LifecycleStrategyMappingRequirement(
+ lifecycleMappingMetadata.getPackagingType(), lifecycleMappingMetadata.getLifecycleMappingId()),
+ new InstallCatalogItemMavenDiscoveryProposal(item));
+ }
}
}
@@ -175,13 +203,25 @@ public class MavenDiscoveryService implements IImportWizardPageFactory, IMavenDi
for(PluginExecutionMetadata executionMapping : entry.getValue()) {
IMavenDiscoveryProposal proposal = getProposal(executionMapping.getSource());
if(proposal != null) {
- put(proposals, new MojoExecutionMappingConfiguration.Key(entry.getKey()), proposal);
+ // assumes installation of mapping proposal installs all required project configurators
+ put(proposals, new MojoExecutionMappingConfiguration.MojoExecutionMappingRequirement(entry.getKey()),
+ proposal);
+ } else if(executionMapping.getAction() == PluginExecutionAction.configurator) {
+ // we have <configurator/> mapping from pom.xml
+ String configuratorId = LifecycleMappingFactory.getProjectConfiguratorId(executionMapping);
+ if(!LifecycleMappingFactory.getProjectConfiguratorExtensions().containsKey(configuratorId)) {
+ // User Story.
+ // Project pom.xml explicitly specifies lifecycle mapping strategy implementation,
+ // but the implementation is not currently installed. As a user I expect m2e to search
+ // marketplace for the implementation and offer installation if available
+
+ if(itemEntry.getProjectConfigurators().contains(configuratorId)) {
+ put(proposals,
+ new MojoExecutionMappingConfiguration.ProjectConfiguratorMappingRequirement(entry.getKey(),
+ configuratorId), new InstallCatalogItemMavenDiscoveryProposal(item));
+ }
+ }
}
- // TODO match eclipse extensions provided by the catalog item
- // User Story.
- // Project pom.xml explicitly specifies lifecycle mapping strategy implementation,
- // but the implementation is not currently installed. As a user I expect m2e to search
- // marketplace for the implementation and offer installation if available
}
}
}
@@ -191,12 +231,13 @@ public class MavenDiscoveryService implements IImportWizardPageFactory, IMavenDi
return proposals;
}
- public void addCatalogItem(CatalogItem item, LifecycleMappingMetadataSource metadataSource) {
+ public void addCatalogItem(CatalogItem item, LifecycleMappingMetadataSource metadataSource,
+ List<String> projectConfigurators, List<String> mappingStrategies) {
if(items == null) {
// for tests
items = new ArrayList<MavenDiscoveryService.CatalogItemCacheEntry>();
}
- items.add(new CatalogItemCacheEntry(item, metadataSource));
+ items.add(new CatalogItemCacheEntry(item, metadataSource, projectConfigurators, mappingStrategies));
}
private IMavenDiscoveryProposal getProposal(LifecycleMappingMetadataSource src) {
@@ -222,8 +263,8 @@ public class MavenDiscoveryService implements IImportWizardPageFactory, IMavenDi
return sources;
}
- private void put(Map<ILifecycleMappingElementKey, List<IMavenDiscoveryProposal>> allproposals,
- ILifecycleMappingElementKey requirement, IMavenDiscoveryProposal proposal) {
+ private void put(Map<ILifecycleMappingRequirement, List<IMavenDiscoveryProposal>> allproposals,
+ ILifecycleMappingRequirement requirement, IMavenDiscoveryProposal proposal) {
List<IMavenDiscoveryProposal> proposals = allproposals.get(requirement);
if(proposals == null) {
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogViewer.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogViewer.java
index 80085556..f517f5b6 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogViewer.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogViewer.java
@@ -12,7 +12,6 @@
package org.eclipse.m2e.internal.discovery.wizards;
import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
import java.util.Collection;
import java.util.Set;
@@ -50,10 +49,6 @@ public class MavenCatalogViewer extends CatalogViewer {
private static final String LIFECYCLE_PREFIX = "lifecycle:"; //$NON-NLS-1$
- private static final String PATH = "lifecycle/"; //$NON-NLS-1$
-
- private static final String EXT = ".xml"; //$NON-NLS-1$
-
private Set<String> installedFeatures;
/*
@@ -224,10 +219,6 @@ public class MavenCatalogViewer extends CatalogViewer {
return false;
}
- public static URL getLifecycleMappingMetadataSourceURL(CatalogItem ci) {
- return ci.getSource().getResource(PATH + ci.getId() + EXT);
- }
-
private static boolean hasPackaging(LifecycleMappingMetadataSource lifecycleMappingMetadataSource,
String packagingType) {
for(LifecycleMappingMetadata lifecycleMappingMetadata : lifecycleMappingMetadataSource.getLifecycleMappings()) {

Back to the top