Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2011-01-21 00:59:03 +0000
committerIgor Fedorenko2011-01-21 01:12:23 +0000
commit97d76db1dc790d33920b0092e4844653a8905027 (patch)
tree72d215d6f9d662aafaffb6bb0f53097e7d24e36f /org.eclipse.m2e.core
parent67626923fd78267af9b3457de128fd37022462ac (diff)
downloadm2e-core-97d76db1dc790d33920b0092e4844653a8905027.tar.gz
m2e-core-97d76db1dc790d33920b0092e4844653a8905027.tar.xz
m2e-core-97d76db1dc790d33920b0092e4844653a8905027.zip
MNGECLIPSE-2724 do not resolve configuration on not interesting mojo executios
Includes patched versions of several maven core classes Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
Diffstat (limited to 'org.eclipse.m2e.core')
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMaven.java6
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java26
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecycle/InvalidLifecycleMapping.java7
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecycle/LifecycleMappingFactory.java66
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java6
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenProjectFacade.java9
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java11
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenProjectFacade.java5
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractCustomizableLifecycleMapping.java109
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/AbstractLifecycleMapping.java7
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/ILifecycleMapping.java4
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/MojoExecutionKey.java86
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/NoopLifecycleMapping.java4
13 files changed, 190 insertions, 156 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMaven.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMaven.java
index 885e7268..090b6783 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMaven.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/IMaven.java
@@ -114,8 +114,10 @@ public interface IMaven {
public void execute(MavenSession session, MojoExecution execution, IProgressMonitor monitor);
- public MavenExecutionPlan calculateExecutionPlan(MavenExecutionRequest request, MavenProject project,
- IProgressMonitor monitor) throws CoreException;
+ public MavenExecutionPlan calculateExecutionPlan(MavenSession session, MavenProject project, List<String> goals,
+ boolean setup, IProgressMonitor monitor) throws CoreException;
+
+ public MojoExecution setupMojoExecution(MavenSession session, MavenProject project, MojoExecution execution) throws CoreException;
public <T> T getMojoParameterValue(MavenSession session, MojoExecution mojoExecution, String parameter,
Class<T> asType) throws CoreException;
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java
index 012b2d84..7be82405 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java
@@ -72,6 +72,7 @@ import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.LifecycleExecutor;
import org.apache.maven.lifecycle.MavenExecutionPlan;
+import org.apache.maven.lifecycle.internal.LifecycleExecutionPlanCalculator;
import org.apache.maven.model.ConfigurationContainer;
import org.apache.maven.model.InputLocation;
import org.apache.maven.model.Model;
@@ -300,18 +301,33 @@ public class MavenImpl implements IMaven, IMavenConfigurationChangeListener {
lookup(MavenPluginManager.class).releaseMojo(mojo, mojoExecution);
}
- public MavenExecutionPlan calculateExecutionPlan(MavenExecutionRequest request, MavenProject project,
- IProgressMonitor monitor) throws CoreException {
- MavenSession session = createSession(request, project);
+ public MavenExecutionPlan calculateExecutionPlan(MavenSession session, MavenProject project, List<String> goals,
+ boolean setup, IProgressMonitor monitor) throws CoreException {
try {
- List<String> goals = request.getGoals();
- return lookup(LifecycleExecutor.class).calculateExecutionPlan(session, goals.toArray(new String[goals.size()]));
+ return lookup(LifecycleExecutor.class).calculateExecutionPlan(session, setup, goals.toArray(new String[goals.size()]));
} catch(Exception ex) {
throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1, NLS.bind(
Messages.MavenImpl_error_calc_build_plan, ex.getMessage()), ex));
}
}
+ public MojoExecution setupMojoExecution(MavenSession session, MavenProject project, MojoExecution execution) throws CoreException {
+ MojoExecution clone = new MojoExecution(execution.getPlugin(), execution.getGoal(), execution.getExecutionId());
+ clone.setMojoDescriptor(execution.getMojoDescriptor());
+ if(execution.getConfiguration() != null) {
+ clone.setConfiguration(new Xpp3Dom(execution.getConfiguration()));
+ }
+ clone.setLifecyclePhase(execution.getLifecyclePhase());
+ LifecycleExecutionPlanCalculator executionPlanCalculator = lookup(LifecycleExecutionPlanCalculator.class);
+ try {
+ executionPlanCalculator.setupMojoExecution(session, project, clone);
+ } catch(Exception ex) {
+ throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1, NLS.bind(
+ Messages.MavenImpl_error_calc_build_plan, ex.getMessage()), ex));
+ }
+ return clone;
+ }
+
public ArtifactRepository getLocalRepository() throws CoreException {
try {
String localRepositoryPath = getLocalRepositoryPath();
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 12bd0880..f6da2b84 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
@@ -19,6 +19,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.apache.maven.plugin.MojoExecution;
+import org.eclipse.m2e.core.internal.lifecycle.model.PluginExecutionMetadata;
import org.eclipse.m2e.core.project.configurator.AbstractBuildParticipant;
import org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping;
import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
@@ -77,7 +78,7 @@ public class InvalidLifecycleMapping extends AbstractLifecycleMapping {
return Collections.emptyList();
}
- public List<MojoExecution> getNotCoveredMojoExecutions(IProgressMonitor monitor) {
+ public List<MojoExecutionKey> getNotCoveredMojoExecutions(IProgressMonitor monitor) {
return Collections.emptyList();
}
@@ -89,8 +90,8 @@ public class InvalidLifecycleMapping extends AbstractLifecycleMapping {
return Collections.emptyMap();
}
- public void initializeMapping(List<MojoExecution> executionPlan, MappingMetadataSource originalMapping,
- List<MappingMetadataSource> inheritedMapping) {
+ public void initializeMapping(List<MojoExecution> mojoExecutions,
+ Map<MojoExecutionKey, List<PluginExecutionMetadata>> executionMapping) {
}
public void addMissingLifecyclePackaging(int line, String message, String 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 2ed14bea..e7181ecd 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
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -50,6 +51,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.apache.maven.execution.DefaultMavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.MavenExecutionPlan;
import org.apache.maven.model.Build;
import org.apache.maven.model.BuildBase;
@@ -77,6 +79,7 @@ import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
import org.eclipse.m2e.core.project.configurator.ILifecycleMapping;
import org.eclipse.m2e.core.project.configurator.LifecycleMappingConfigurationException;
import org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant;
+import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
import org.eclipse.m2e.core.project.configurator.NoopLifecycleMapping;
@@ -231,14 +234,67 @@ public class LifecycleMappingFactory {
// PHASE 2. Bind project configurators to mojo executions.
//
- // XXX the plan is to avoid resolving execution plan and use MavenProject directly for performance and reliability reason
IMaven maven = MavenPlugin.getDefault().getMaven();
- MavenExecutionRequest request = DefaultMavenExecutionRequest.copy(templateRequest); // TODO ain't pretty
- request.setGoals(Arrays.asList("deploy"));
- MavenExecutionPlan executionPlan = maven.calculateExecutionPlan(request, mavenProject, monitor);
+ MavenSession session = maven.createSession(DefaultMavenExecutionRequest.copy(templateRequest), mavenProject);
+ List<String> goals = Arrays.asList("deploy"); //$NON-NLS-1$
+ MavenExecutionPlan executionPlan = maven.calculateExecutionPlan(session, mavenProject, goals, false, monitor);
+
+ Map<MojoExecutionKey, List<PluginExecutionMetadata>> executionMapping = new LinkedHashMap<MojoExecutionKey, List<PluginExecutionMetadata>>();
+ List<MojoExecution> mojoExecutions = new ArrayList<MojoExecution>();
+
+ for(MojoExecution execution : executionPlan.getMojoExecutions()) {
+ MojoExecutionKey executionKey = new MojoExecutionKey(execution);
+
+ PluginExecutionMetadata primaryMetadata = null;
+
+ // find primary mapping first
+ try {
+ for(MappingMetadataSource source : metadataSources) {
+ for(PluginExecutionMetadata executionMetadata : source.getPluginExecutionMetadata(execution)) {
+ if(LifecycleMappingFactory.isPrimaryMapping(executionMetadata)) {
+ if(primaryMetadata != null) {
+ primaryMetadata = null;
+ throw new DuplicateMappingException();
+ }
+ primaryMetadata = executionMetadata;
+ }
+ }
+ if(primaryMetadata != null) {
+ break;
+ }
+ }
+ } catch(DuplicateMappingException e) {
+ lifecycleMapping.addProblem(1, NLS.bind(Messages.PluginExecutionMappingDuplicate, executionKey.toString()));
+ }
+
+ List<PluginExecutionMetadata> executionMetadatas = new ArrayList<PluginExecutionMetadata>();
+ if(primaryMetadata != null) {
+ executionMetadatas.add(primaryMetadata);
+
+ // attach any secondary mapping
+ for(MappingMetadataSource source : metadataSources) {
+ List<PluginExecutionMetadata> metadatas = source.getPluginExecutionMetadata(execution);
+ if(metadatas != null) {
+ for(PluginExecutionMetadata metadata : metadatas) {
+ if(LifecycleMappingFactory.isSecondaryMapping(metadata, primaryMetadata)) {
+ executionMetadatas.add(metadata);
+ }
+ }
+ }
+ }
+
+ executionMapping.put(executionKey, executionMetadatas);
+ }
+ if(!executionMetadatas.isEmpty() && executionMetadatas.get(0).getAction() != PluginExecutionAction.ignore) {
+ mojoExecutions.add(maven.setupMojoExecution(session, mavenProject, execution));
+ } else {
+ // do not setup non-interesting/ignore mojo executions
+ mojoExecutions.add(execution);
+ }
+ }
lifecycleMapping.setMavenProjectFacade(projectFacade);
- lifecycleMapping.initializeMapping(executionPlan.getMojoExecutions(), originalMetadataSource, metadataSources);
+ lifecycleMapping.initializeMapping(mojoExecutions, executionMapping);
return lifecycleMapping;
}
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 59a2fa67..5c4c115d 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
@@ -60,7 +60,6 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Model;
-import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.project.MavenProject;
import org.eclipse.m2e.core.MavenPlugin;
@@ -90,6 +89,7 @@ import org.eclipse.m2e.core.project.ResolverConfiguration;
import org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping;
import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
import org.eclipse.m2e.core.project.configurator.ILifecycleMapping;
+import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
import org.eclipse.m2e.core.project.configurator.ProjectConfigurationRequest;
import org.eclipse.m2e.core.util.Util;
@@ -360,9 +360,9 @@ public class ProjectConfigurationManager implements IProjectConfigurationManager
return false;
}
- List<MojoExecution> notCoveredMojoExecutions = lifecycleMapping.getNotCoveredMojoExecutions(monitor);
+ List<MojoExecutionKey> notCoveredMojoExecutions = lifecycleMapping.getNotCoveredMojoExecutions(monitor);
if(notCoveredMojoExecutions != null && notCoveredMojoExecutions.size() != 0) {
- for(MojoExecution mojoExecution : notCoveredMojoExecutions) {
+ for(MojoExecutionKey mojoExecution : notCoveredMojoExecutions) {
IMarker marker = mavenMarkerManager.addMarker(
mavenProjectFacade.getPom(),
IMavenConstants.MARKER_CONFIGURATION_ID,
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenProjectFacade.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenProjectFacade.java
index 19b9fbab..69f1ac36 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenProjectFacade.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/MavenProjectFacade.java
@@ -31,7 +31,6 @@ import org.eclipse.core.runtime.Status;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.execution.MavenExecutionResult;
-import org.apache.maven.lifecycle.MavenExecutionPlan;
import org.apache.maven.project.MavenProject;
import org.eclipse.m2e.core.MavenPlugin;
@@ -59,7 +58,6 @@ public class MavenProjectFacade implements IMavenProjectFacade, Serializable {
private final File pomFile;
private transient MavenProject mavenProject;
- private transient MavenExecutionPlan executionPlan;
private transient Map<String, Object> sessionProperties;
@@ -206,13 +204,6 @@ public class MavenProjectFacade implements IMavenProjectFacade, Serializable {
return mavenProject;
}
- public synchronized MavenExecutionPlan getExecutionPlan(IProgressMonitor monitor) throws CoreException {
- if (executionPlan == null) {
- executionPlan = manager.calculateExecutionPlan(this, monitor);
- }
- return executionPlan;
- }
-
public String getPackaging() {
return packaging;
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java
index ef9fe68e..c5da8d6c 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/registry/ProjectRegistryManager.java
@@ -51,7 +51,6 @@ import org.apache.maven.execution.DefaultMavenExecutionRequest;
import org.apache.maven.execution.DefaultMavenExecutionResult;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
-import org.apache.maven.lifecycle.MavenExecutionPlan;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.apache.maven.project.MavenProject;
@@ -581,16 +580,6 @@ public class ProjectRegistryManager {
return lifecycleMapping;
}
- MavenExecutionPlan calculateExecutionPlan(MavenProjectFacade facade, IProgressMonitor monitor) throws CoreException {
- return calculateExecutionPlan(projectRegistry, facade, monitor);
- }
-
- private MavenExecutionPlan calculateExecutionPlan(IProjectRegistry state, MavenProjectFacade facade, IProgressMonitor monitor) throws CoreException {
- MavenExecutionRequest request = createExecutionRequest(state, facade.getPom(), facade.getResolverConfiguration(), monitor);
- request.setGoals(Arrays.asList("deploy")); //$NON-NLS-1$
- return getMaven().calculateExecutionPlan(request, facade.getMavenProject(monitor), monitor);
- }
-
public IFile getModulePom(IFile pom, String moduleName) {
return pom.getParent().getFile(new Path(moduleName).append(IMavenConstants.POM_FILE_NAME));
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenProjectFacade.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenProjectFacade.java
index 944e9243..67468c7a 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenProjectFacade.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/IMavenProjectFacade.java
@@ -86,11 +86,6 @@ public interface IMavenProjectFacade {
*/
MavenProject getMavenProject();
- /**
- * Lazy load and cache build execution plan
- */
- MavenExecutionPlan getExecutionPlan(IProgressMonitor monitor) throws CoreException;
-
String getPackaging();
IProject getProject();
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 5397084e..ad9ac268 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,17 +16,13 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osgi.util.NLS;
-import org.apache.maven.lifecycle.MavenExecutionPlan;
import org.apache.maven.plugin.MojoExecution;
import org.eclipse.m2e.core.internal.Messages;
-import org.eclipse.m2e.core.internal.lifecycle.DuplicateMappingException;
import org.eclipse.m2e.core.internal.lifecycle.LifecycleMappingFactory;
-import org.eclipse.m2e.core.internal.lifecycle.MappingMetadataSource;
import org.eclipse.m2e.core.internal.lifecycle.model.PluginExecutionAction;
import org.eclipse.m2e.core.internal.lifecycle.model.PluginExecutionMetadata;
@@ -42,12 +38,19 @@ public abstract class AbstractCustomizableLifecycleMapping extends AbstractLifec
private Map<String, AbstractProjectConfigurator> configurators;
+ private List<MojoExecution> executionPlan;
+
+ private List<MojoExecutionKey> notCoveredExecutions;
+
@Override
- public void initializeMapping(List<MojoExecution> executionPlan, MappingMetadataSource originalMapping,
- List<MappingMetadataSource> inheritedMapping) {
+ public void initializeMapping(List<MojoExecution> mojoExecutions,
+ Map<MojoExecutionKey, List<PluginExecutionMetadata>> executionMapping) {
+
+ this.effectiveMapping = executionMapping;
- this.effectiveMapping = getEffectiveMapping(executionPlan, originalMapping, inheritedMapping);
+ this.executionPlan = mojoExecutions;
+ // instantiate configurator
this.configurators = new LinkedHashMap<String, AbstractProjectConfigurator>();
for(List<PluginExecutionMetadata> executionMetadatas : effectiveMapping.values()) {
for(PluginExecutionMetadata executionMetadata : executionMetadatas) {
@@ -63,64 +66,37 @@ public abstract class AbstractCustomizableLifecycleMapping extends AbstractLifec
}
}
}
- }
- protected Map<MojoExecutionKey, List<PluginExecutionMetadata>> getEffectiveMapping(List<MojoExecution> executionPlan,
- MappingMetadataSource originalMapping, List<MappingMetadataSource> inheritedMapping) {
- Map<MojoExecutionKey, List<PluginExecutionMetadata>> executionMapping = new LinkedHashMap<MojoExecutionKey, List<PluginExecutionMetadata>>();
-
- for(MojoExecution execution : executionPlan) {
- PluginExecutionMetadata primaryMetadata = null;
-
- // find primary mapping first
- try {
- for(MappingMetadataSource source : inheritedMapping) {
- for(PluginExecutionMetadata executionMetadata : source.getPluginExecutionMetadata(execution)) {
- if(LifecycleMappingFactory.isPrimaryMapping(executionMetadata)) {
- if(primaryMetadata != null) {
- primaryMetadata = null;
- throw new DuplicateMappingException();
- }
- primaryMetadata = executionMetadata;
- }
- }
- if(primaryMetadata != null) {
- break;
- }
- }
- } catch(DuplicateMappingException e) {
- addProblem(1, NLS.bind(Messages.PluginExecutionMappingDuplicate, execution.toString()));
+ // find and cache not-covered mojo execution keys
+ notCoveredExecutions = new ArrayList<MojoExecutionKey>();
+ all_mojo_executions: for(MojoExecution mojoExecution : executionPlan) {
+ if(!isInterestingPhase(mojoExecution.getLifecyclePhase())) {
+ continue;
}
-
- if(primaryMetadata != null) {
- List<PluginExecutionMetadata> executionMetadatas = new ArrayList<PluginExecutionMetadata>();
- executionMetadatas.add(primaryMetadata);
-
- // attach any secondary mapping
- for(MappingMetadataSource source : inheritedMapping) {
- List<PluginExecutionMetadata> metadatas = source.getPluginExecutionMetadata(execution);
- if(metadatas != null) {
- for(PluginExecutionMetadata metadata : metadatas) {
- if(LifecycleMappingFactory.isSecondaryMapping(metadata, primaryMetadata)) {
- executionMetadatas.add(metadata);
+ MojoExecutionKey executionKey = new MojoExecutionKey(mojoExecution);
+ List<PluginExecutionMetadata> executionMetadatas = effectiveMapping.get(executionKey);
+ if(executionMetadatas != null) {
+ for(PluginExecutionMetadata executionMetadata : executionMetadatas) {
+ switch(executionMetadata.getAction()) {
+ case ignore:
+ case execute:
+ continue all_mojo_executions;
+ case configurator:
+ if(configurators.containsKey(LifecycleMappingFactory.getProjectConfiguratorId(executionMetadata))) {
+ continue all_mojo_executions;
}
- }
}
}
-
- executionMapping.put(new MojoExecutionKey(execution), executionMetadatas);
}
+ notCoveredExecutions.add(executionKey);
}
- return executionMapping;
}
- public Map<MojoExecutionKey, List<AbstractBuildParticipant>> getBuildParticipants(IProgressMonitor monitor)
- throws CoreException {
+ public Map<MojoExecutionKey, List<AbstractBuildParticipant>> getBuildParticipants(IProgressMonitor monitor) {
Map<MojoExecutionKey, List<AbstractBuildParticipant>> result = new LinkedHashMap<MojoExecutionKey, List<AbstractBuildParticipant>>();
- MavenExecutionPlan executionPlan = getMavenProjectFacade().getExecutionPlan(monitor);
- for(MojoExecution mojoExecution : executionPlan.getMojoExecutions()) {
+ for(MojoExecution mojoExecution : executionPlan) {
MojoExecutionKey executionKey = new MojoExecutionKey(mojoExecution);
List<AbstractBuildParticipant> executionMappings = new ArrayList<AbstractBuildParticipant>();
List<PluginExecutionMetadata> executionMetadatas = effectiveMapping.get(executionKey);
@@ -155,30 +131,7 @@ public abstract class AbstractCustomizableLifecycleMapping extends AbstractLifec
return new ArrayList<AbstractProjectConfigurator>(configurators.values());
}
- public List<MojoExecution> getNotCoveredMojoExecutions(IProgressMonitor monitor) throws CoreException {
- List<MojoExecution> result = new ArrayList<MojoExecution>();
-
- MavenExecutionPlan executionPlan = getMavenProjectFacade().getExecutionPlan(monitor);
- all_mojo_executions: for(MojoExecution mojoExecution : executionPlan.getMojoExecutions()) {
- if(!isInterestingPhase(mojoExecution.getLifecyclePhase())) {
- continue;
- }
- List<PluginExecutionMetadata> executionMetadatas = effectiveMapping.get(new MojoExecutionKey(mojoExecution));
- if(executionMetadatas != null) {
- for(PluginExecutionMetadata executionMetadata : executionMetadatas) {
- switch(executionMetadata.getAction()) {
- case ignore:
- case execute:
- continue all_mojo_executions;
- case configurator:
- if(configurators.containsKey(LifecycleMappingFactory.getProjectConfiguratorId(executionMetadata))) {
- continue all_mojo_executions;
- }
- }
- }
- }
- result.add(mojoExecution);
- }
- return result;
+ public List<MojoExecutionKey> getNotCoveredMojoExecutions(IProgressMonitor monitor) {
+ return notCoveredExecutions;
}
}
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 5a40f7fc..fb721d99 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
@@ -13,6 +13,7 @@ package org.eclipse.m2e.core.project.configurator;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
@@ -24,7 +25,7 @@ import org.eclipse.core.runtime.OperationCanceledException;
import org.apache.maven.plugin.MojoExecution;
import org.eclipse.m2e.core.core.IMavenConstants;
-import org.eclipse.m2e.core.internal.lifecycle.MappingMetadataSource;
+import org.eclipse.m2e.core.internal.lifecycle.model.PluginExecutionMetadata;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
@@ -219,7 +220,7 @@ public abstract class AbstractLifecycleMapping implements ILifecycleMapping {
this.mavenProjectFacade = projectFacade;
}
- public abstract void initializeMapping(List<MojoExecution> executionPlan, MappingMetadataSource originalMapping,
- List<MappingMetadataSource> inheritedMapping);
+ public abstract void initializeMapping(List<MojoExecution> mojoExecutions,
+ Map<MojoExecutionKey, List<PluginExecutionMetadata>> executionMapping);
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/ILifecycleMapping.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/ILifecycleMapping.java
index c4f2f91e..b3404e19 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/ILifecycleMapping.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/ILifecycleMapping.java
@@ -17,8 +17,6 @@ import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.apache.maven.plugin.MojoExecution;
-
/**
* LifecycleMapping
*
@@ -50,7 +48,7 @@ public interface ILifecycleMapping {
//TODO Return Set instead of List
List<AbstractProjectConfigurator> getProjectConfigurators(IProgressMonitor monitor) throws CoreException;
- List<MojoExecution> getNotCoveredMojoExecutions(IProgressMonitor monitor)
+ List<MojoExecutionKey> getNotCoveredMojoExecutions(IProgressMonitor monitor)
throws CoreException;
boolean isInterestingPhase(String phase);
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 2be4d631..b89f42da 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
@@ -8,30 +8,42 @@
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
+
package org.eclipse.m2e.core.project.configurator;
import org.apache.maven.plugin.MojoExecution;
public class MojoExecutionKey {
- private final MojoExecution mojoExecution;
- public MojoExecutionKey(MojoExecution mojoExecution) {
- this.mojoExecution = mojoExecution;
- }
+ private final String groupId;
+
+ private final String artifactId;
+
+ private final String version;
+
+ private final String goal;
+
+ private final String executionId;
- public MojoExecution getMojoExecution() {
- return mojoExecution;
+ private final String lifecyclePhase;
+
+ public MojoExecutionKey(MojoExecution mojoExecution) {
+ this.groupId = mojoExecution.getGroupId();
+ this.artifactId = mojoExecution.getArtifactId();
+ this.version = mojoExecution.getVersion();
+ this.goal = mojoExecution.getGoal();
+ this.executionId = mojoExecution.getExecutionId();
+ this.lifecyclePhase = mojoExecution.getLifecyclePhase();
}
public int hashCode() {
- int hash = mojoExecution.getGroupId().hashCode();
- hash = 17 * hash + mojoExecution.getArtifactId().hashCode();
- hash = 17 * hash + mojoExecution.getVersion().hashCode();
- hash = 17 * mojoExecution.getGoal().hashCode();
- if(mojoExecution.getExecutionId() != null) {
- hash = 17 * mojoExecution.getExecutionId().hashCode();
- }
+ 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();
return hash;
}
@@ -45,22 +57,44 @@ public class MojoExecutionKey {
MojoExecutionKey other = (MojoExecutionKey) obj;
- boolean equals = mojoExecution.getGroupId().equals(other.mojoExecution.getGroupId())
- && mojoExecution.getArtifactId().equals(other.mojoExecution.getArtifactId())
- && mojoExecution.getVersion().equals(other.mojoExecution.getVersion())
- && mojoExecution.getGoal().equals(other.mojoExecution.getGoal());
- if(!equals) {
- return false;
- }
+ 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);
+ }
- if(mojoExecution.getExecutionId() == null) {
- return other.mojoExecution.getExecutionId() == null;
- }
- return mojoExecution.getExecutionId().equals(other.mojoExecution.getExecutionId());
+ public String getGroupId() {
+ return this.groupId;
+ }
+
+ public String getArtifactId() {
+ return this.artifactId;
+ }
+
+ public String getVersion() {
+ return this.version;
+ }
+
+ public String getGoal() {
+ return this.goal;
+ }
+
+ public String getExecutionId() {
+ return this.executionId;
+ }
+
+ public String getLifecyclePhase() {
+ return lifecyclePhase;
}
public String getKeyString() {
- return mojoExecution.getGroupId() + ":" + mojoExecution.getArtifactId() + ":" + mojoExecution.getVersion() + ":"
- + mojoExecution.getGoal() + ":" + mojoExecution.getExecutionId();
+ return groupId + ":" + artifactId + ":" + version + ":" + goal + ":" + executionId + ":" + lifecyclePhase;
+ }
+
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(groupId).append(":").append(artifactId).append(":").append(version);
+ sb.append(":").append(goal);
+ sb.append(" {execution: ").append(executionId).append("}");
+ return sb.toString();
}
}
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/NoopLifecycleMapping.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/NoopLifecycleMapping.java
index fd696f9e..d87e059a 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/NoopLifecycleMapping.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/project/configurator/NoopLifecycleMapping.java
@@ -17,8 +17,6 @@ import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.apache.maven.plugin.MojoExecution;
-
/**
* NoopLifecycleMapping
@@ -45,7 +43,7 @@ public class NoopLifecycleMapping implements ILifecycleMapping {
return Collections.emptyList();
}
- public List<MojoExecution> getNotCoveredMojoExecutions(IProgressMonitor monitor) {
+ public List<MojoExecutionKey> getNotCoveredMojoExecutions(IProgressMonitor monitor) {
return Collections.emptyList();
}

Back to the top