Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2011-02-02 20:36:24 +0000
committerIgor Fedorenko2011-02-02 20:48:56 +0000
commit68443fde8e72144d925de3c36200d4e4247ac94c (patch)
treeb56122575624d9499593b1edd88d7327a8325fbf /org.eclipse.m2e.tests.common
parentebb733d48dac3806b45ae8e350543c587665096d (diff)
downloadm2e-core-68443fde8e72144d925de3c36200d4e4247ac94c.tar.gz
m2e-core-68443fde8e72144d925de3c36200d4e4247ac94c.tar.xz
m2e-core-68443fde8e72144d925de3c36200d4e4247ac94c.zip
335719: error marker when project configuration update is required
Separated project effective lifecycle mapping metadata and made it persistent member of MavenProjectFacade. LifecycleMapping instances do not have any project specific state as a result of this change. Added (partially implemented) logic to perform effective lifecycle mapping metadata comparison during whenever project pom.xml change is detected. Error marker is added to project if mapping has change and/or interesting mojo execution configuration has changed. Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
Diffstat (limited to 'org.eclipse.m2e.tests.common')
-rw-r--r--org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractLifecycleMappingTest.java59
-rw-r--r--org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java1
2 files changed, 55 insertions, 5 deletions
diff --git a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractLifecycleMappingTest.java b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractLifecycleMappingTest.java
index 6a04f96e..6011860c 100644
--- a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractLifecycleMappingTest.java
+++ b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractLifecycleMappingTest.java
@@ -15,34 +15,53 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.core.internal.resources.Workspace;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.lifecycle.MavenExecutionPlan;
+import org.apache.maven.project.MavenProject;
+
import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.internal.lifecycle.LifecycleMappingFactory;
import org.eclipse.m2e.core.internal.lifecycle.model.LifecycleMappingMetadataSource;
+import org.eclipse.m2e.core.internal.lifecycle.model.PluginExecutionMetadata;
import org.eclipse.m2e.core.internal.lifecycle.model.io.xpp3.LifecycleMappingMetadataSourceXpp3Reader;
+import org.eclipse.m2e.core.internal.project.registry.MavenProjectFacade;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.IProjectConfigurationManager;
import org.eclipse.m2e.core.project.MavenProjectManager;
import org.eclipse.m2e.core.project.ResolverConfiguration;
+import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
@SuppressWarnings("restriction")
public abstract class AbstractLifecycleMappingTest extends AbstractMavenProjectTestCase {
protected MavenProjectManager mavenProjectManager;
+
protected IProjectConfigurationManager projectConfigurationManager;
@Override
protected void setUp() throws Exception {
super.setUp();
-
+
mavenProjectManager = MavenPlugin.getDefault().getMavenProjectManager();
projectConfigurationManager = MavenPlugin.getDefault().getProjectConfigurationManager();
}
-
+
@Override
protected void tearDown() throws Exception {
projectConfigurationManager = null;
@@ -50,7 +69,7 @@ public abstract class AbstractLifecycleMappingTest extends AbstractMavenProjectT
super.tearDown();
}
-
+
protected IMavenProjectFacade importMavenProject(String basedir, String pomName) throws Exception {
ResolverConfiguration configuration = new ResolverConfiguration();
IProject[] project = importProjects(basedir, new String[] {pomName}, configuration);
@@ -72,4 +91,36 @@ public abstract class AbstractLifecycleMappingTest extends AbstractMavenProjectT
IOUtil.close(in);
}
}
-} \ No newline at end of file
+
+ /**
+ * Creates new partially initialised MavenProjectFacade instance
+ */
+ protected MavenProjectFacade newMavenProjectFacade(String path) throws CoreException {
+ File file = new File(path);
+ IFile pom = (IFile) ((Workspace) workspace).newResource(Path.fromOSString(file.getAbsolutePath()), IResource.FILE);
+ MavenProject mavenProject = plugin.getMaven().readProject(file, monitor);
+ MavenExecutionRequest request = plugin.getMaven().createExecutionRequest(monitor);
+ MavenSession session = plugin.getMaven().createSession(request, mavenProject);
+ MavenExecutionPlan executionPlan = plugin.getMaven().calculateExecutionPlan(session, mavenProject,
+ Arrays.asList("deploy"), false, monitor);
+ MavenProjectFacade facade = new MavenProjectFacade(null, pom, mavenProject, executionPlan.getMojoExecutions(), null);
+ return facade;
+ }
+
+ protected List<MojoExecutionKey> getNotCoveredMojoExecutions(IMavenProjectFacade facade) {
+ List<MojoExecutionKey> result = new ArrayList<MojoExecutionKey>();
+
+ Map<MojoExecutionKey, List<PluginExecutionMetadata>> executionMapping = facade.getMojoExecutionMapping();
+
+ for(Map.Entry<MojoExecutionKey, List<PluginExecutionMetadata>> entry : executionMapping.entrySet()) {
+ if(entry.getValue() == null || entry.getValue().isEmpty()) {
+ if (LifecycleMappingFactory.isInterestingPhase(entry.getKey().getLifecyclePhase())) {
+ result.add(entry.getKey());
+ }
+ }
+ }
+
+ return result;
+ }
+
+}
diff --git a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java
index d12c697c..01c1f1c1 100644
--- a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java
+++ b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java
@@ -458,5 +458,4 @@ public abstract class AbstractMavenProjectTestCase extends TestCase {
container.addComponentDescriptor(descriptor);
}
}
-
}

Back to the top