Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Piggott2011-04-19 17:24:53 -0400
committerMatthew Piggott2011-04-19 17:24:53 -0400
commitc0c5ddb0a296fafdededd4756289fc84824d65cf (patch)
tree7a4c1e4a5e965c5ab09bfa199cd70e3920ffe405 /org.eclipse.m2e.editor
parent536624a9235d244dd0d192a0a916643a80163ccd (diff)
downloadm2e-core-c0c5ddb0a296fafdededd4756289fc84824d65cf.tar.gz
m2e-core-c0c5ddb0a296fafdededd4756289fc84824d65cf.tar.xz
m2e-core-c0c5ddb0a296fafdededd4756289fc84824d65cf.zip
Bug 342768 - Adding a managed dependency in the POM editor adds version to that dependency
Diffstat (limited to 'org.eclipse.m2e.editor')
-rw-r--r--org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java23
1 files changed, 22 insertions, 1 deletions
diff --git a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
index 623cc95a..eb3ebca3 100644
--- a/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
+++ b/org.eclipse.m2e.editor/src/org/eclipse/m2e/editor/composites/DependenciesComposite.java
@@ -21,6 +21,7 @@ import java.util.LinkedList;
import java.util.List;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.DependencyManagement;
import org.apache.maven.project.MavenProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
@@ -255,7 +256,8 @@ public class DependenciesComposite extends Composite {
Element depsEl = getChild(document.getDocumentElement(), DEPENDENCIES);
PomHelper.addOrUpdateDependency(depsEl,
dep.group, dep.artifact,
- dep.version, dep.type, selectedScope, dep.classifier);
+ isManaged(dep.group, dep.artifact, dep.version) ? null : dep.version, dep.type, selectedScope,
+ dep.classifier);
}
}, log, "errror adding dependency");
} finally {
@@ -959,6 +961,25 @@ public class DependenciesComposite extends Composite {
return toRet;
}
+ private boolean isManaged(String groupId, String artifactId, String version) {
+ if(version == null) {
+ return true;
+ }
+ DependencyManagement depManagement = editorPage.getPomEditor().getMavenProject().getDependencyManagement();
+ if(depManagement != null && groupId != null && artifactId != null) {
+ List<org.apache.maven.model.Dependency> managedDep = depManagement.getDependencies();
+ if(managedDep != null) {
+ for(org.apache.maven.model.Dependency dependency : managedDep) {
+ if(version.equals(dependency.getVersion()) && artifactId.equals(dependency.getArtifactId())
+ && groupId.equals(dependency.getGroupId())) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
class Dependency implements IAdaptable {
String artifactId;
String groupId;

Back to the top