Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Piggott2011-04-14 19:50:01 +0000
committerMatthew Piggott2011-04-14 19:51:00 +0000
commitf577d68e46ec30be919d30b0ca46c6b57cad2b6b (patch)
treee58c6f182211368f71477ac9e27be568f7eb9418 /org.eclipse.m2e.core
parent8eaaec7cefcb9b92a9a6bc9c4afc1dd11b10c082 (diff)
downloadm2e-core-f577d68e46ec30be919d30b0ca46c6b57cad2b6b.tar.gz
m2e-core-f577d68e46ec30be919d30b0ca46c6b57cad2b6b.tar.xz
m2e-core-f577d68e46ec30be919d30b0ca46c6b57cad2b6b.zip
Bug 339968 - Lifecycle Mapping Page improvements
- passed.png from http://code.google.com/a/eclipselabs.org/p/workspacemechanic/
Diffstat (limited to 'org.eclipse.m2e.core')
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/M2EUtils.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/M2EUtils.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/M2EUtils.java
index 7a1e5104..39ce9339 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/M2EUtils.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/M2EUtils.java
@@ -12,6 +12,9 @@
package org.eclipse.m2e.core.internal;
import java.io.File;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
import java.util.Stack;
import org.eclipse.core.resources.IContainer;
@@ -23,8 +26,11 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.apache.maven.model.Plugin;
import org.apache.maven.project.MavenProject;
+import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
+
public class M2EUtils {
@@ -96,4 +102,34 @@ public class M2EUtils {
}
return stack.empty() ? null : stack.pop();
}
+
+ public static Collection<MavenProject> getDefiningProjects(MojoExecutionKey key, Collection<MavenProject> projects) {
+ Set<MavenProject> sourceProjects = new HashSet<MavenProject>();
+ for (MavenProject project : projects) {
+ if(definesPlugin(project, key)) {
+ sourceProjects.add(project);
+ continue;
+ }
+ for(MavenProject parent = project.getParent(); parent != null; parent = parent.getParent()) {
+ if(definesPlugin(parent, key)) {
+ sourceProjects.add(parent);
+ // Only the first instance is necessary
+ break;
+ }
+ }
+ }
+ return sourceProjects;
+ }
+
+ public static boolean definesPlugin(MavenProject project, MojoExecutionKey key) {
+ if(project.getOriginalModel().getBuild() == null) {
+ return false;
+ }
+ for(Plugin p : project.getOriginalModel().getBuild().getPlugins()) {
+ if(p.getGroupId().equals(key.getGroupId()) && p.getArtifactId().equals(key.getArtifactId())) {
+ return true;
+ }
+ }
+ return false;
+ }
}

Back to the top