summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMatthew Piggott2011-01-19 17:40:33 (EST)
committer vladt2011-01-21 14:14:56 (EST)
commit98d1f94dc3681c6cbc82ead5be0298f2e53af938 (patch)
treea24c167d27b5446b043487b5576b29cf427c9275
parent77bb6242cb20039cd615142adbccc0fef4c37003 (diff)
downloadm2e-core-98d1f94dc3681c6cbc82ead5be0298f2e53af938.zip
m2e-core-98d1f94dc3681c6cbc82ead5be0298f2e53af938.tar.gz
m2e-core-98d1f94dc3681c6cbc82ead5be0298f2e53af938.tar.bz2
MNGECLIPSE-2746 - Added quickfix support for missing configurators and lifecycles
General cleanup on CatalogItem selection code
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/core/IMavenConstants.java6
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecycle/InvalidLifecycleMapping.java21
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecycle/LifecycleMappingFactory.java5
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java9
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractCustomizableLifecycleMapping.java29
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractLifecycleMapping.java5
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscovery.java19
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/Messages.java4
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/handlers/MavenDiscoveryHandler.java6
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/DiscoveryWizardProposal.java36
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/MavenDiscoveryMarkerResolutionGenerator.java11
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/messages.properties2
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogConfiguration.java28
-rw-r--r--org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogViewer.java114
-rw-r--r--org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/WorkspaceHelpers.java61
15 files changed, 253 insertions, 103 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/core/IMavenConstants.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/core/IMavenConstants.java
index e1a1d12..39822a6 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/core/IMavenConstants.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/core/IMavenConstants.java
@@ -76,6 +76,8 @@ public interface IMavenConstants {
public static final String MARKER_ATTR_ARTIFACT_ID = "artifactId";
+ public static final String MARKER_ATTR_CONFIGURATOR_ID = "configuratorId";
+
public static final String MARKER_ATTR_EXECUTION_ID = "executionId";
public static final String MARKER_ATTR_GOAL = "goal";
@@ -97,7 +99,11 @@ public interface IMavenConstants {
public static final String EDITOR_HINT_MISSING_SCHEMA = "missing_schema";
public static final String EDITOR_HINT_NOT_COVERED_MOJO_EXECUTION = "not_covered_mojo_execution";
+
+ public static final String EDITOR_HINT_UNKNOWN_LIFECYCLE_ID = "unknown_lifecycle_id";
+ public static final String EDITOR_HINT_MISSING_CONFIGURATOR = "missing_configurator";
+
public static final String EDITOR_HINT_UNKNOWN_PACKAGING = "unknown_packaging_type";
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecycle/InvalidLifecycleMapping.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecycle/InvalidLifecycleMapping.java
index f6da2b8..73748d7 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecycle/InvalidLifecycleMapping.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecycle/InvalidLifecycleMapping.java
@@ -15,11 +15,15 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.apache.maven.plugin.MojoExecution;
+import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.internal.lifecycle.model.PluginExecutionMetadata;
+import org.eclipse.m2e.core.internal.project.MarkerUtils;
import org.eclipse.m2e.core.project.configurator.AbstractBuildParticipant;
import org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping;
import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
@@ -45,6 +49,13 @@ public class InvalidLifecycleMapping extends AbstractLifecycleMapping {
public String getLifecycleId() {
return lifecycleId;
}
+
+ @Override
+ public void processMarker(IMarker marker) throws CoreException {
+ MarkerUtils.decorateMarker(marker);
+ marker.setAttribute(IMavenConstants.MARKER_ATTR_LIFECYCLE_PHASE, getLifecycleId());
+ marker.setAttribute(IMavenConstants.MARKER_ATTR_EDITOR_HINT, IMavenConstants.EDITOR_HINT_UNKNOWN_LIFECYCLE_ID);
+ }
}
public static class MissingLifecyclePackaging extends LifecycleMappingProblemInfo {
@@ -58,6 +69,12 @@ public class InvalidLifecycleMapping extends AbstractLifecycleMapping {
public String getPackaging() {
return packaging;
}
+
+ @Override
+ public void processMarker(IMarker marker) throws CoreException {
+ marker.setAttribute(IMavenConstants.MARKER_ATTR_PACKAGING, getPackaging());
+ marker.setAttribute(IMavenConstants.MARKER_ATTR_EDITOR_HINT, IMavenConstants.EDITOR_HINT_UNKNOWN_PACKAGING);
+ }
}
public String getId() {
@@ -94,6 +111,10 @@ public class InvalidLifecycleMapping extends AbstractLifecycleMapping {
Map<MojoExecutionKey, List<PluginExecutionMetadata>> executionMapping) {
}
+ public void addMissingLifecycleExtensionPoint(int line, String message, String lifecycleId) {
+ addProblem(new MissingLifecycleExtensionPoint(line, message, lifecycleId));
+ }
+
public void addMissingLifecyclePackaging(int line, String message, String packaging) {
addProblem(new MissingLifecyclePackaging(line, message, packaging));
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecycle/LifecycleMappingFactory.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecycle/LifecycleMappingFactory.java
index e7181ec..2b82c73 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecycle/LifecycleMappingFactory.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecycle/LifecycleMappingFactory.java
@@ -225,8 +225,9 @@ public class LifecycleMappingFactory {
AbstractLifecycleMapping lifecycleMapping = getLifecycleMapping(lifecycleMappingMetadata.getLifecycleMappingId());
if(lifecycleMapping == null) {
- invalidLifecycleMapping.addProblem(1,
- NLS.bind(Messages.LifecycleMappingNotAvailable, lifecycleMappingMetadata.getLifecycleMappingId()));
+ invalidLifecycleMapping.addMissingLifecycleExtensionPoint(1,
+ NLS.bind(Messages.LifecycleMappingNotAvailable, lifecycleMappingMetadata.getLifecycleMappingId()),
+ lifecycleMappingMetadata.getLifecycleMappingId());
return invalidLifecycleMapping;
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java
index 09304ee..0c1b4c0 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java
@@ -338,14 +338,7 @@ public class ProjectConfigurationManager implements IProjectConfigurationManager
for (AbstractLifecycleMapping.LifecycleMappingProblemInfo problem : ((AbstractLifecycleMapping)lifecycleMapping).getProblems()) {
IMarker marker = mavenMarkerManager.addMarker(mavenProjectFacade.getPom(), IMavenConstants.MARKER_CONFIGURATION_ID,
problem.getMessage(), problem.getLine(), IMarker.SEVERITY_ERROR);
- // TODO do something with associated cause
- if (problem instanceof InvalidLifecycleMapping.MissingLifecycleExtensionPoint) {
- marker.setAttribute("lifecycleId", ((InvalidLifecycleMapping.MissingLifecycleExtensionPoint) problem).getLifecycleId());
- } else if(problem instanceof InvalidLifecycleMapping.MissingLifecyclePackaging) {
- marker.setAttribute(IMavenConstants.MARKER_ATTR_PACKAGING, mavenProjectFacade.getPackaging());
- marker.setAttribute(IMavenConstants.MARKER_ATTR_EDITOR_HINT, IMavenConstants.EDITOR_HINT_UNKNOWN_PACKAGING);
- MarkerUtils.decorateMarker(marker);
- }
+ problem.processMarker(marker);
}
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractCustomizableLifecycleMapping.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractCustomizableLifecycleMapping.java
index ad9ac26..167e879 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractCustomizableLifecycleMapping.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractCustomizableLifecycleMapping.java
@@ -16,11 +16,14 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osgi.util.NLS;
import org.apache.maven.plugin.MojoExecution;
+import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.internal.Messages;
import org.eclipse.m2e.core.internal.lifecycle.LifecycleMappingFactory;
import org.eclipse.m2e.core.internal.lifecycle.model.PluginExecutionAction;
@@ -34,6 +37,25 @@ import org.eclipse.m2e.core.internal.lifecycle.model.PluginExecutionMetadata;
*/
public abstract class AbstractCustomizableLifecycleMapping extends AbstractLifecycleMapping {
+ public static class MissingConfiguratorProblemInfo extends LifecycleMappingProblemInfo {
+ private final String configuratorId;
+
+ public MissingConfiguratorProblemInfo(int line, String message, String configuratorId) {
+ super(line, message);
+ this.configuratorId = configuratorId;
+ }
+
+ public String getConfiguratorId() {
+ return configuratorId;
+ }
+
+ @Override
+ public void processMarker(IMarker marker) throws CoreException {
+ marker.setAttribute(IMavenConstants.MARKER_ATTR_CONFIGURATOR_ID, getConfiguratorId());
+ marker.setAttribute(IMavenConstants.MARKER_ATTR_EDITOR_HINT, IMavenConstants.EDITOR_HINT_MISSING_CONFIGURATOR);
+ }
+ }
+
private Map<MojoExecutionKey, List<PluginExecutionMetadata>> effectiveMapping;
private Map<String, AbstractProjectConfigurator> configurators;
@@ -60,7 +82,8 @@ public abstract class AbstractCustomizableLifecycleMapping extends AbstractLifec
try {
configurators.put(configuratorId, LifecycleMappingFactory.createProjectConfigurator(executionMetadata));
} catch(LifecycleMappingConfigurationException e) {
- addProblem(1, NLS.bind(Messages.ProjectConfiguratorNotAvailable, configuratorId));
+ addMissingConfiguratorProblem(1, NLS.bind(Messages.ProjectConfiguratorNotAvailable, configuratorId),
+ configuratorId);
}
}
}
@@ -134,4 +157,8 @@ public abstract class AbstractCustomizableLifecycleMapping extends AbstractLifec
public List<MojoExecutionKey> getNotCoveredMojoExecutions(IProgressMonitor monitor) {
return notCoveredExecutions;
}
+
+ public void addMissingConfiguratorProblem(int line, String message, String configuratorId) {
+ super.addProblem(new MissingConfiguratorProblemInfo(line, message, configuratorId));
+ }
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractLifecycleMapping.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractLifecycleMapping.java
index fb721d9..90a5c9c 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractLifecycleMapping.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractLifecycleMapping.java
@@ -16,6 +16,7 @@ import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
@@ -53,6 +54,10 @@ public abstract class AbstractLifecycleMapping implements ILifecycleMapping {
public String getMessage() {
return message;
}
+
+ public void processMarker(IMarker marker) throws CoreException {
+
+ }
}
private String name;
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 04652ab..38b624a 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
@@ -13,6 +13,7 @@ package org.eclipse.m2e.internal.discovery;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import org.apache.maven.plugin.MojoExecution;
@@ -41,16 +42,22 @@ public class MavenDiscovery {
private static final String PATH = "http://download.eclipse.org/technology/m2e/discovery/directory.xml"; //$NON-NLS-1$
- public static void launchWizard(final Collection<String> packagingTypes, final Collection<MojoExecution> mojos) {
+ public static void launchWizard(Shell shell) {
+ launchWizard(shell, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
+ }
+
+ public static void launchWizard(final Collection<String> packagingTypes, final Collection<MojoExecution> mojos,
+ final Collection<String> lifecycleIds, final Collection<String> configuratorIds) {
final Display display = Workbench.getInstance().getDisplay();
display.asyncExec(new Runnable() {
public void run() {
- launchWizard(display.getActiveShell(), packagingTypes, mojos);
+ launchWizard(display.getActiveShell(), packagingTypes, mojos, lifecycleIds, configuratorIds);
}
});
}
- public static void launchWizard(Shell shell, Collection<String> packagingTypes, Collection<MojoExecution> mojos) {
+ public static void launchWizard(Shell shell, Collection<String> packagingTypes, Collection<MojoExecution> mojos,
+ Collection<String> lifecycleIds, Collection<String> configuratorIds) {
Catalog catalog = new Catalog();
catalog.setEnvironment(DiscoveryCore.createEnvironment());
catalog.setVerifyUpdateSiteAvailability(false);
@@ -62,7 +69,7 @@ public class MavenDiscovery {
// Build the list of tags to show in the Wizard header
List<Tag> tags = new ArrayList<Tag>(3);
- if(!packagingTypes.isEmpty()) {
+ if(!packagingTypes.isEmpty() || !mojos.isEmpty() || !configuratorIds.isEmpty() || !lifecycleIds.isEmpty()) {
tags.add(APPLICABLE_TAG);
}
tags.add(EXTRAS_TAG);
@@ -73,7 +80,7 @@ public class MavenDiscovery {
// Create configuration for the catalog
MavenCatalogConfiguration configuration = new MavenCatalogConfiguration();
configuration.setShowTagFilter(true);
- if(!packagingTypes.isEmpty()) {
+ if(!packagingTypes.isEmpty() || !mojos.isEmpty() || !configuratorIds.isEmpty() || !lifecycleIds.isEmpty()) {
tags = new ArrayList<Tag>(1);
tags.add(APPLICABLE_TAG);
configuration.setSelectedTags(tags);
@@ -83,6 +90,8 @@ public class MavenDiscovery {
configuration.setShowInstalledFilter(false);
configuration.setSelectedPackagingTypes(packagingTypes);
configuration.setSelectedMojos(mojos);
+ configuration.setSelectedLifecycleIds(lifecycleIds);
+ configuration.setSelectedConfigurators(configuratorIds);
MavenDiscoveryWizard wizard = new MavenDiscoveryWizard(catalog, configuration);
WizardDialog dialog = new WizardDialog(shell, wizard);
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/Messages.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/Messages.java
index 7935a35..c4c8ba5 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/Messages.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/Messages.java
@@ -29,10 +29,6 @@ public class Messages extends NLS {
public static String MavenCatalogViewer_Error_loading_lifecycle;
- public static String MavenCatalogViewer_Missing_mojo_execution;
-
- public static String MavenCatalogViewer_Missing_packaging_type;
-
public static String MavenDiscoveryWizard_Title;
public static String MavenDiscovery_Wizard_Applicable_Tag;
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/handlers/MavenDiscoveryHandler.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/handlers/MavenDiscoveryHandler.java
index 36cf645..bb488d3 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/handlers/MavenDiscoveryHandler.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/handlers/MavenDiscoveryHandler.java
@@ -11,8 +11,6 @@
package org.eclipse.m2e.internal.discovery.handlers;
-import java.util.Collections;
-
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
@@ -22,10 +20,8 @@ import org.eclipse.ui.handlers.HandlerUtil;
public class MavenDiscoveryHandler extends AbstractHandler {
- @SuppressWarnings("unchecked")
public Object execute(ExecutionEvent event) throws ExecutionException {
- MavenDiscovery.launchWizard(HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(), Collections.EMPTY_LIST,
- Collections.EMPTY_LIST);
+ MavenDiscovery.launchWizard(HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell());
return null;
}
}
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/DiscoveryWizardProposal.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/DiscoveryWizardProposal.java
index 4c253f6..f9b8a05 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/DiscoveryWizardProposal.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/DiscoveryWizardProposal.java
@@ -12,7 +12,6 @@
package org.eclipse.m2e.internal.discovery.markers;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -29,18 +28,27 @@ import org.eclipse.ui.views.markers.WorkbenchMarkerResolution;
class DiscoveryWizardProposal extends WorkbenchMarkerResolution {
- static final DiscoveryWizardProposal PROPOSAL = new DiscoveryWizardProposal();
+ private IMarker marker;
+
+ public DiscoveryWizardProposal(IMarker marker) {
+ this.marker = marker;
+ }
@SuppressWarnings("unchecked")
public void run(IMarker marker) {
String type = marker.getAttribute(IMavenConstants.MARKER_ATTR_EDITOR_HINT, null);
if(IMavenConstants.EDITOR_HINT_UNKNOWN_PACKAGING.equals(type)) {
- MavenDiscovery.launchWizard(Arrays.asList(new String[] {getPackageType(marker)}), Collections.EMPTY_LIST);
+ MavenDiscovery.launchWizard(Collections.singleton(getPackageType(marker)), Collections.EMPTY_LIST,
+ Collections.EMPTY_LIST, Collections.EMPTY_LIST);
} else if(IMavenConstants.EDITOR_HINT_NOT_COVERED_MOJO_EXECUTION.equals(type)) {
MavenDiscovery
- .launchWizard(Collections.EMPTY_LIST, Arrays.asList(new MojoExecution[] {getMojoExecution(marker)}));
+ .launchWizard(Collections.EMPTY_LIST, Collections.singleton(getMojoExecution(marker)), Collections.EMPTY_LIST, Collections.EMPTY_LIST);
+ } else if(IMavenConstants.EDITOR_HINT_UNKNOWN_LIFECYCLE_ID.equals(type)) {
+ MavenDiscovery.launchWizard(Collections.EMPTY_LIST, Collections.EMPTY_LIST,
+ Collections.singleton(getLifecycleId(marker)), Collections.EMPTY_LIST);
+ } else if(IMavenConstants.EDITOR_HINT_MISSING_CONFIGURATOR.equals(type)) {
+ MavenDiscovery.launchWizard(Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.singleton(getConfiguratorId(marker)));
}
-
}
public String getDescription() {
@@ -53,17 +61,23 @@ class DiscoveryWizardProposal extends WorkbenchMarkerResolution {
@Override
public void run(IMarker[] markers, IProgressMonitor monitor) {
+ List<String> lifecycleIds = new ArrayList<String>();
List<String> packagingTypes = new ArrayList<String>();
List<MojoExecution> mojos = new ArrayList<MojoExecution>();
+ List<String> configuratorIds = new ArrayList<String>();
for(IMarker marker : markers) {
String type = marker.getAttribute(IMavenConstants.MARKER_ATTR_EDITOR_HINT, null);
if(IMavenConstants.EDITOR_HINT_UNKNOWN_PACKAGING.equals(type)) {
packagingTypes.add(getPackageType(marker));
} else if(IMavenConstants.EDITOR_HINT_NOT_COVERED_MOJO_EXECUTION.equals(type)) {
mojos.add(getMojoExecution(marker));
+ } else if(IMavenConstants.EDITOR_HINT_UNKNOWN_LIFECYCLE_ID.equals(type)) {
+ lifecycleIds.add(getLifecycleId(marker));
+ } else if(IMavenConstants.EDITOR_HINT_MISSING_CONFIGURATOR.equals(type)) {
+ configuratorIds.add(getConfiguratorId(marker));
}
}
- MavenDiscovery.launchWizard(packagingTypes, mojos);
+ MavenDiscovery.launchWizard(packagingTypes, mojos, lifecycleIds, configuratorIds);
}
private MojoExecution getMojoExecution(IMarker marker) {
@@ -90,11 +104,19 @@ class DiscoveryWizardProposal extends WorkbenchMarkerResolution {
return marker.getAttribute(IMavenConstants.MARKER_ATTR_PACKAGING, null);
}
+ private String getLifecycleId(IMarker marker) {
+ return marker.getAttribute(IMavenConstants.MARKER_ATTR_LIFECYCLE_PHASE, null);
+ }
+
+ private String getConfiguratorId(IMarker marker) {
+ return marker.getAttribute(IMavenConstants.MARKER_ATTR_CONFIGURATOR_ID, null);
+ }
+
@Override
public IMarker[] findOtherMarkers(IMarker[] markers) {
List<IMarker> handled = new ArrayList<IMarker>();
for(IMarker marker : markers) {
- if(MavenDiscoveryMarkerResolutionGenerator.canResolve(marker)) {
+ if(marker != this.marker && MavenDiscoveryMarkerResolutionGenerator.canResolve(marker)) {
handled.add(marker);
}
}
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/MavenDiscoveryMarkerResolutionGenerator.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/MavenDiscoveryMarkerResolutionGenerator.java
index 6242c9f..76633e0 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/MavenDiscoveryMarkerResolutionGenerator.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/markers/MavenDiscoveryMarkerResolutionGenerator.java
@@ -25,11 +25,8 @@ public class MavenDiscoveryMarkerResolutionGenerator implements IMarkerResolutio
}
public IMarkerResolution[] getResolutions(IMarker marker) {
- String type = marker.getAttribute(IMavenConstants.MARKER_ATTR_EDITOR_HINT, null);
- if(IMavenConstants.EDITOR_HINT_UNKNOWN_PACKAGING.equals(type)) {
- return new IMarkerResolution[] {DiscoveryWizardProposal.PROPOSAL};
- } else if(IMavenConstants.EDITOR_HINT_NOT_COVERED_MOJO_EXECUTION.equals(type)) {
- return new IMarkerResolution[] {DiscoveryWizardProposal.PROPOSAL};
+ if(canResolve(marker)) {
+ return new IMarkerResolution[] {new DiscoveryWizardProposal(marker)};
}
return new IMarkerResolution[0];
}
@@ -37,6 +34,8 @@ public class MavenDiscoveryMarkerResolutionGenerator implements IMarkerResolutio
public static boolean canResolve(IMarker marker) {
String type = marker.getAttribute(IMavenConstants.MARKER_ATTR_EDITOR_HINT, null);
return IMavenConstants.EDITOR_HINT_UNKNOWN_PACKAGING.equals(type)
- || IMavenConstants.EDITOR_HINT_NOT_COVERED_MOJO_EXECUTION.equals(type);
+ || IMavenConstants.EDITOR_HINT_MISSING_CONFIGURATOR.equals(type)
+ || IMavenConstants.EDITOR_HINT_NOT_COVERED_MOJO_EXECUTION.equals(type)
+ || IMavenConstants.EDITOR_HINT_UNKNOWN_LIFECYCLE_ID.equals(type);
}
}
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/messages.properties b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/messages.properties
index b109c9f..df0f775 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/messages.properties
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/messages.properties
@@ -10,8 +10,6 @@ DiscoveryWizardProposal_Label=Discover new maven plugin connectors
MavenCatalogPage_Descripton=Select updates and extensions to install. Press Finish to proceed with installation.\nPress the information button to see a detailed overview and a link to more information.
MavenCatalogPage_Title=Install Maven Plugins
MavenCatalogViewer_Error_loading_lifecycle=An error occurred loading lifecycle data for catalog item: {0}
-MavenCatalogViewer_Missing_packaging_type=No relevant CatalogItem found for packaging type: {0}
-MavenCatalogViewer_Missing_mojo_execution=No relevant CatalogItem found for MojoExecution {0} {1} {2} {3}
MavenDiscoveryWizard_Title=Maven Discovery
MavenDiscovery_Wizard_Applicable_Tag=Applicable
MavenDiscovery_Wizard_ExtrasTag=Extras
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogConfiguration.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogConfiguration.java
index 3af0ea3..6a6201a 100644
--- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogConfiguration.java
+++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenCatalogConfiguration.java
@@ -26,6 +26,18 @@ public class MavenCatalogConfiguration extends CatalogConfiguration {
private Set<MojoExecution> selectedMojos;
+ private Set<String> selectedLifecycleIds;
+
+ private Set<String> selectedConfiguratorIds;
+
+ public Collection<String> getSelectedLifecycleIds() {
+ return selectedLifecycleIds;
+ }
+
+ public Collection<String> getSelectedConfiguratorIds() {
+ return selectedConfiguratorIds;
+ }
+
public Collection<MojoExecution> getSelectedMojos() {
return selectedMojos;
}
@@ -55,4 +67,20 @@ public class MavenCatalogConfiguration extends CatalogConfiguration {
selectedMojos.addAll(mojos);
}
}
+
+ public void setSelectedLifecycleIds(Collection<String> lifecycleIds) {
+ if(selectedLifecycleIds == null) {
+ selectedLifecycleIds = new HashSet<String>(lifecycleIds);
+ } else {
+ selectedLifecycleIds.addAll(lifecycleIds);
+ }
+ }
+
+ public void setSelectedConfigurators(Collection<String> configuratorIds) {
+ if(selectedConfiguratorIds == null) {
+ selectedConfiguratorIds = new HashSet<String>(configuratorIds);
+ } else {
+ selectedConfiguratorIds.addAll(configuratorIds);
+ }
+ }
}
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 84239ba..07c3267 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
@@ -13,17 +13,13 @@ package org.eclipse.m2e.internal.discovery.wizards;
import java.net.URL;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
import org.apache.maven.plugin.MojoExecution;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.discovery.Catalog;
import org.eclipse.equinox.internal.p2.discovery.model.CatalogItem;
+import org.eclipse.equinox.internal.p2.discovery.model.Tag;
import org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogConfiguration;
import org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogViewer;
import org.eclipse.jface.operation.IRunnableContext;
@@ -42,12 +38,14 @@ import org.eclipse.osgi.util.NLS;
@SuppressWarnings("restriction")
public class MavenCatalogViewer extends CatalogViewer {
+ private static final String CONFIGURATOR_PREFIX = "configurator:"; //$NON-NLS-1$
+
+ 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 Map<CatalogItem, LifecycleMappingMetadataSource> lifecycleCache = new HashMap<CatalogItem, LifecycleMappingMetadataSource>();
-
public MavenCatalogViewer(Catalog catalog, IShellProvider shellProvider, IRunnableContext context,
CatalogConfiguration configuration) {
super(catalog, shellProvider, context, configuration);
@@ -60,90 +58,80 @@ public class MavenCatalogViewer extends CatalogViewer {
final MavenCatalogConfiguration config = (MavenCatalogConfiguration) getConfiguration();
final Collection<String> selectedPackagingTypes = config.getSelectedPackagingTypes();
final Collection<MojoExecution> selectedMojos = config.getSelectedMojos();
+ final Collection<String> selectedLifecycleIds = config.getSelectedLifecycleIds();
+ final Collection<String> selectedConfiguratorIds = config.getSelectedConfiguratorIds();
shellProvider.getShell().getDisplay().syncExec(new Runnable() {
@SuppressWarnings("synthetic-access")
public void run() {
- Map<String, Set<CatalogItem>> map = new HashMap<String, Set<CatalogItem>>(selectedPackagingTypes.size());
-
- for(String packagingType : selectedPackagingTypes) {
- map.put(packagingType, new HashSet<CatalogItem>());
- for(CatalogItem ci : getCatalog().getItems()) {
- LifecycleMappingMetadataSource src = getLifecycleMappingMetadataSource(ci);
- if(src != null && hasPackaging(src, packagingType)) {
- Set<CatalogItem> items = map.get(packagingType);
- items.add(ci);
+ for (CatalogItem ci : getCatalog().getItems()) {
+ boolean selected = false;
+
+ LifecycleMappingMetadataSource src = getLifecycleMappingMetadataSource(ci);
+ if (src != null) {
+ for (String packagingType : selectedPackagingTypes) {
+ if(hasPackaging(src, packagingType)) {
+ selected = true;
+ select(ci);
+ break;
+ }
}
- }
- }
-
- Map<MojoExecution, Set<CatalogItem>> mojoMap = new HashMap<MojoExecution, Set<CatalogItem>>(selectedMojos
- .size());
- // Mojo
- for(MojoExecution mojoExecution : selectedMojos) {
- mojoMap.put(mojoExecution, new HashSet<CatalogItem>());
- for(CatalogItem ci : getCatalog().getItems()) {
- LifecycleMappingMetadataSource src = getLifecycleMappingMetadataSource(ci);
- if(src != null && matchesFilter(src, mojoExecution)) {
- mojoMap.get(mojoExecution).add(ci);
+ if (selected) {
+ continue;
+ }
+ for(MojoExecution mojoExecution : selectedMojos) {
+ if (matchesFilter(src, mojoExecution)) {
+ selected = true;
+ select(ci);
+ break;
+ }
+ }
+ if (selected) {
+ continue;
}
}
- }
- // Select relevant CatalogItems
- // TODO Make selection smarter
- for(Entry<String, Set<CatalogItem>> type : map.entrySet()) {
- if(type.getValue().isEmpty()) {
- MavenLogger.log(NLS.bind(Messages.MavenCatalogViewer_Missing_packaging_type, type.getKey()));
+ for(String configuratorId : selectedConfiguratorIds) {
+ Tag configuratorIdTag = new Tag(CONFIGURATOR_PREFIX + configuratorId, CONFIGURATOR_PREFIX + configuratorId);
+ if (ci.hasTag(configuratorIdTag)) {
+ selected = true;
+ select(ci);
+ break;
+ }
}
- for(CatalogItem ci : type.getValue()) {
- modifySelection(ci, true);
- ci.addTag(MavenDiscovery.APPLICABLE_TAG);
+ if (selected) {
+ continue;
}
- }
- for(Entry<MojoExecution, Set<CatalogItem>> type : mojoMap.entrySet()) {
- if(type.getValue().isEmpty()) {
- MavenLogger.log(NLS.bind(Messages.MavenCatalogViewer_Missing_mojo_execution, new String[] {
- type.getKey().getGroupId(), type.getKey().getArtifactId(), type.getKey().getExecutionId(),
- type.getKey().getGoal()}));
- }
- for(CatalogItem ci : type.getValue()) {
- modifySelection(ci, true);
- ci.addTag(MavenDiscovery.APPLICABLE_TAG);
+ for(String lifecycleId : selectedLifecycleIds) {
+ Tag lifecycleIdTag = new Tag(LIFECYCLE_PREFIX + lifecycleId, LIFECYCLE_PREFIX + lifecycleId);
+ if (ci.hasTag(lifecycleIdTag)) {
+ select(ci);
+ break;
+ }
}
}
}
});
}
+ private void select(CatalogItem ci) {
+ modifySelection(ci, true);
+ ci.addTag(MavenDiscovery.APPLICABLE_TAG);
+ }
+
private static boolean matchesFilter(LifecycleMappingMetadataSource src, MojoExecution mojoExecution) {
for(PluginExecutionMetadata p : src.getPluginExecutions()) {
if(p.getFilter().match(mojoExecution)) {
return true;
}
}
- for(LifecycleMappingMetadata m : src.getLifecycleMappings()) {
- for(PluginExecutionMetadata p : m.getPluginExecutions()) {
- if(p.getFilter().match(mojoExecution)) {
- return true;
- }
- }
- }
return false;
}
private LifecycleMappingMetadataSource getLifecycleMappingMetadataSource(CatalogItem ci) {
try {
- if(lifecycleCache.get(ci) != null) {
- return lifecycleCache.get(ci);
- }
- LifecycleMappingMetadataSource source = LifecycleMappingFactory
- .createLifecycleMappingMetadataSource(getLifecycleMappingMetadataSourceURL(ci));
- if(source != null) {
- lifecycleCache.put(ci, source);
- }
- return source;
+ return LifecycleMappingFactory.createLifecycleMappingMetadataSource(getLifecycleMappingMetadataSourceURL(ci));
} catch(Exception e) {
MavenLogger.log(new Status(IStatus.WARNING, MavenDiscoveryIcons.PLUGIN_ID, NLS.bind(
Messages.MavenCatalogViewer_Error_loading_lifecycle,
diff --git a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/WorkspaceHelpers.java b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/WorkspaceHelpers.java
index c04bedc..8b4823f 100644
--- a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/WorkspaceHelpers.java
+++ b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/WorkspaceHelpers.java
@@ -38,6 +38,7 @@ import org.eclipse.core.runtime.Status;
import org.codehaus.plexus.util.FileUtils;
import org.eclipse.m2e.core.core.IMavenConstants;
+import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
public class WorkspaceHelpers {
@@ -231,4 +232,64 @@ public class WorkspaceHelpers {
return actual;
}
+
+ public static void assertLifecycleIdErrorMarkerAttributes(IProject project, String lifecycleId) throws CoreException {
+ List<IMarker> errorMarkers = WorkspaceHelpers.findErrorMarkers(project);
+ Assert.assertNotNull(errorMarkers);
+ Assert.assertEquals(WorkspaceHelpers.toString(errorMarkers), 1, errorMarkers.size());
+ }
+
+ public static void assertConfiguratorErrorMarkerAttributes(IProject project, String configuratorId)
+ throws CoreException {
+ List<IMarker> errorMarkers = WorkspaceHelpers.findErrorMarkers(project);
+ Assert.assertNotNull(errorMarkers);
+ Assert.assertEquals(WorkspaceHelpers.toString(errorMarkers), 1, errorMarkers.size());
+ assertConfiguratorErrorMarkerAttributes(errorMarkers.get(0), configuratorId);
+ }
+
+ public static void assertLifecyclePackagingErrorMarkerAttributes(IProject project, String packagingType)
+ throws CoreException {
+ List<IMarker> errorMarkers = WorkspaceHelpers.findErrorMarkers(project);
+ Assert.assertNotNull(errorMarkers);
+ Assert.assertEquals(WorkspaceHelpers.toString(errorMarkers), 1, errorMarkers.size());
+ }
+
+ public static void assertLifecycleIdErrorMarkerAttributes(IMarker marker, String lifecycleId) {
+ Assert.assertEquals("Marker's editor hint", IMavenConstants.EDITOR_HINT_UNKNOWN_LIFECYCLE_ID,
+ marker.getAttribute(IMavenConstants.MARKER_ATTR_EDITOR_HINT, null));
+ Assert.assertEquals("Marker's lifecycle", lifecycleId,
+ marker.getAttribute(IMavenConstants.MARKER_ATTR_LIFECYCLE_PHASE, null));
+ }
+
+ public static void assertConfiguratorErrorMarkerAttributes(IMarker marker, String configuratorId) {
+ Assert.assertEquals("Marker's ConfiguratorID", configuratorId,
+ marker.getAttribute(IMavenConstants.MARKER_ATTR_CONFIGURATOR_ID, null));
+ Assert.assertEquals("Marker's editor hint", IMavenConstants.EDITOR_HINT_MISSING_CONFIGURATOR,
+ marker.getAttribute(IMavenConstants.MARKER_ATTR_EDITOR_HINT, null));
+ }
+
+ public static void assertLifecyclePackagingErrorMarkerAttributes(IMarker marker, String packagingType) {
+ Assert.assertEquals("Marker's editor hint", IMavenConstants.EDITOR_HINT_UNKNOWN_PACKAGING,
+ marker.getAttribute(IMavenConstants.MARKER_ATTR_EDITOR_HINT, null));
+ Assert.assertEquals("Marker's packagingType", packagingType,
+ marker.getAttribute(IMavenConstants.MARKER_ATTR_PACKAGING, null));
+ }
+
+ public static void assertErrorMarkerAttributes(IMarker marker, MojoExecutionKey mojoExecution) {
+ Assert.assertEquals(IMavenConstants.EDITOR_HINT_NOT_COVERED_MOJO_EXECUTION,
+ marker.getAttribute(IMavenConstants.MARKER_ATTR_EDITOR_HINT, null));
+ //TODO what parameters are important here for the hints?
+ Assert.assertEquals("Marker's groupID", mojoExecution.getGroupId(),
+ marker.getAttribute(IMavenConstants.MARKER_ATTR_GROUP_ID, null));
+ Assert.assertEquals("Marker's artifactId", mojoExecution.getArtifactId(),
+ marker.getAttribute(IMavenConstants.MARKER_ATTR_ARTIFACT_ID, null));
+ Assert.assertEquals("Marker's executionId", mojoExecution.getExecutionId(),
+ marker.getAttribute(IMavenConstants.MARKER_ATTR_EXECUTION_ID, null));
+ Assert.assertEquals("Marker's goal", mojoExecution.getGoal(),
+ marker.getAttribute(IMavenConstants.MARKER_ATTR_GOAL, null));
+ Assert.assertEquals("Marker's version", mojoExecution.getVersion(),
+ marker.getAttribute(IMavenConstants.MARKER_ATTR_VERSION, null));
+ Assert.assertEquals("Marker's lifecyclePhase", mojoExecution.getLifecyclePhase(),
+ marker.getAttribute(IMavenConstants.MARKER_ATTR_LIFECYCLE_PHASE, null));
+ }
}