Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Tanasenko2015-05-26 16:16:53 -0400
committerAnton Tanasenko2015-05-26 16:16:53 -0400
commita5cfba5bf398df277f3ee6f7f85fd7c856ed32bb (patch)
treed9f16acbd6954208eac29f71289de3f1e7f3bc89 /org.eclipse.m2e.core
parent3e7111c55ca2b5c5ef62d4655dcbac7723ae842d (diff)
downloadm2e-core-a5cfba5bf398df277f3ee6f7f85fd7c856ed32bb.tar.gz
m2e-core-a5cfba5bf398df277f3ee6f7f85fd7c856ed32bb.tar.xz
m2e-core-a5cfba5bf398df277f3ee6f7f85fd7c856ed32bb.zip
468164 Missing dependency marker with imported dependencyManagement;releases/1.6/1.6.0.20150526-2032milestones/1.6/1.6.0.20150526-2032
also fix an npe regression Change-Id: Id04f3d905d17989d8f6e4bea8ca244fcf6afe547 Signed-off-by: Anton Tanasenko <atg.sleepless@gmail.com>
Diffstat (limited to 'org.eclipse.m2e.core')
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/markers/SourceLocationHelper.java37
1 files changed, 36 insertions, 1 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/markers/SourceLocationHelper.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/markers/SourceLocationHelper.java
index 24dec05e..c2b8d4ca 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/markers/SourceLocationHelper.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/markers/SourceLocationHelper.java
@@ -144,17 +144,52 @@ public class SourceLocationHelper {
return pluginExecution.getLocation(SELF);
}
- private static org.apache.maven.model.Dependency getMavenDependency(MavenProject mavenProject, Dependency dependency) {
+ private static org.apache.maven.model.Dependency getMavenDependency(MavenProject mavenProject,
+ Dependency dependency) {
org.apache.maven.model.Dependency found = findDependency(mavenProject.getDependencies(), dependency);
if(found == null) {
DependencyManagement depMgmt = mavenProject.getModel().getDependencyManagement();
if(depMgmt != null) {
found = findDependency(depMgmt.getDependencies(), dependency);
+
+ if(found != null) {
+
+ // missing transitive managed dependency
+ String projectId = mavenProject.getModel().getLocation(SELF).getSource().getModelId();
+ String depId = found.getLocation(SELF).getSource().getModelId();
+
+ if(!projectId.equals(depId)) {
+ // let's see if it comes from a directly imported pom
+ DependencyManagement origMgmt = mavenProject.getOriginalModel().getDependencyManagement();
+ org.apache.maven.model.Dependency importDep = findDependencyImport(origMgmt, depId);
+ if(importDep != null) {
+ // use it to show marker on
+ found = importDep;
+ } else {
+ found = null;
+ }
+ }
+ }
}
}
return found;
}
+ private static org.apache.maven.model.Dependency findDependencyImport(DependencyManagement origMgmt, String depId) {
+ if(origMgmt != null) {
+ for(org.apache.maven.model.Dependency dependency : origMgmt.getDependencies()) {
+
+ if("import".equals(dependency.getScope()) && "pom".equals(dependency.getType())) {
+ String importId = dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + dependency.getVersion();
+ if(depId.equals(importId)) {
+ return dependency;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
private static org.apache.maven.model.Dependency findDependency(List<org.apache.maven.model.Dependency> dependencies,
Dependency dependency) {
for(org.apache.maven.model.Dependency mavenDependency : dependencies) {

Back to the top