Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Bricon2015-01-25 12:17:49 -0500
committerFred Bricon2015-01-25 12:17:49 -0500
commited44306cf76f1ae0d89a82edaf1b893c4c479498 (patch)
treee89a56736d78bcf3994637ed529762fd6515eb66 /org.eclipse.m2e.editor.xml
parent811edb90f43f10b1276ca3786de5f8f064fae699 (diff)
downloadm2e-core-ed44306cf76f1ae0d89a82edaf1b893c4c479498.tar.gz
m2e-core-ed44306cf76f1ae0d89a82edaf1b893c4c479498.tar.xz
m2e-core-ed44306cf76f1ae0d89a82edaf1b893c4c479498.zip
355882 : fix unexpected 'Overriding managed version' markers
Change-Id: I428844cb9816cb8f1487e285c73b604af99f3462 Signed-off-by: Fred Bricon <fbricon@gmail.com>
Diffstat (limited to 'org.eclipse.m2e.editor.xml')
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerLocationService.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerLocationService.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerLocationService.java
index 909c46f3..bda31fbd 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerLocationService.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerLocationService.java
@@ -344,8 +344,9 @@ public class MarkerLocationService implements IMarkerLocationService, IEditorMar
if(deps != null) {
for(Dependency dep : deps) {
if(dep.getVersion() != null) { //#335366
- //shall we be using geManagementkey() here? but it contains also the type, not only the gr+art ids..
- managed.put(dep.getGroupId() + ":" + dep.getArtifactId(), dep.getVersion()); //$NON-NLS-1$
+ //355882 use dep.getManagementKey() to prevent false positives
+ //when type or classifier doesn't match
+ managed.put(dep.getManagementKey(), dep.getVersion());
}
}
}
@@ -358,7 +359,9 @@ public class MarkerLocationService implements IMarkerLocationService, IEditorMar
String artString = getTextValue(findChild(dep, PomEdits.ARTIFACT_ID));
String versionString = getTextValue(version);
if(grpString != null && artString != null && versionString != null) {
- String id = grpString + ":" + artString; //$NON-NLS-1$
+ String typeString = getTextValue(findChild(dep, PomEdits.TYPE));
+ String classifier = getTextValue(findChild(dep, PomEdits.CLASSIFIER));
+ String id = getDependencyKey(grpString, artString, typeString, classifier);
if(managed.containsKey(id)) {
String managedVersion = managed.get(id);
if(version instanceof IndexedRegion) {
@@ -374,8 +377,8 @@ public class MarkerLocationService implements IMarkerLocationService, IEditorMar
IMavenConstants.EDITOR_HINT_MANAGED_DEPENDENCY_OVERRIDE);
mark.setAttribute(IMarker.CHAR_START, off.getStartOffset());
mark.setAttribute(IMarker.CHAR_END, off.getEndOffset());
- mark.setAttribute("problemType", "pomhint"); //only imporant in case we enable the generic xml quick fixes //$NON-NLS-1$ //$NON-NLS-2$
- //add these attributes to easily and deterministicaly find the declaration in question
+ mark.setAttribute("problemType", "pomhint"); //only important in case we enable the generic xml quick fixes //$NON-NLS-1$ //$NON-NLS-2$
+ //add these attributes to easily and deterministically find the declaration in question
mark.setAttribute("groupId", grpString); //$NON-NLS-1$
mark.setAttribute("artifactId", artString); //$NON-NLS-1$
String profile = candidateProfile.get(dep);
@@ -388,6 +391,15 @@ public class MarkerLocationService implements IMarkerLocationService, IEditorMar
}
}
+ private static String getDependencyKey(String groupId, String artifactId, String type, String classifier) {
+ StringBuilder key = new StringBuilder(groupId).append(":").append(artifactId).append(":") //$NON-NLS-1$ //$NON-NLS-2$
+ .append(type == null ? "jar" : type);//$NON-NLS-1$
+ if(classifier != null) {
+ key.append(":").append(classifier);//$NON-NLS-1$
+ }
+ return key.toString();
+ }
+
private static void checkManagedPlugins(IMavenMarkerManager mavenMarkerManager, Element root, IResource pomFile,
MavenProject mavenproject, String type, IStructuredDocument document) throws CoreException {
List<Element> candidates = new ArrayList<Element>();

Back to the top