diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-10-08 16:29:21 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-10-08 16:29:21 +0200 |
commit | 8833d880ca4ea5bd2c24f3ede76a3831b9b324ab (patch) | |
tree | c7f5cb15d5538bb35a479cea2a32ab10f964e379 /plugins | |
parent | d671ed5664c30dac695725ec1ce726fe404e20c5 (diff) | |
download | sonarqube-8833d880ca4ea5bd2c24f3ede76a3831b9b324ab.tar.gz sonarqube-8833d880ca4ea5bd2c24f3ede76a3831b9b324ab.zip |
SONAR-1587 Fix inter module dependencies when sonar.branch is used
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/MavenDependenciesSensor.java | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/MavenDependenciesSensor.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/MavenDependenciesSensor.java index 088b3d182b7..ce900fd67c8 100644 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/MavenDependenciesSensor.java +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/MavenDependenciesSensor.java @@ -34,10 +34,10 @@ import org.apache.maven.shared.dependency.tree.traversal.BuildingDependencyNodeV import org.apache.maven.shared.dependency.tree.traversal.CollectingDependencyNodeVisitor; import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor; import org.apache.maven.shared.dependency.tree.traversal.FilteringDependencyNodeVisitor; -import org.sonar.api.batch.SupportedEnvironment; import org.sonar.api.batch.Sensor; import org.sonar.api.batch.SensorContext; import org.sonar.api.batch.SonarIndex; +import org.sonar.api.batch.SupportedEnvironment; import org.sonar.api.design.Dependency; import org.sonar.api.resources.Library; import org.sonar.api.resources.Project; @@ -55,7 +55,7 @@ public class MavenDependenciesSensor implements Sensor { private SonarIndex index; public MavenDependenciesSensor(ArtifactRepository localRepository, ArtifactFactory artifactFactory, ArtifactMetadataSource artifactMetadataSource, - ArtifactCollector artifactCollector, DependencyTreeBuilder treeBuilder, SonarIndex index) { + ArtifactCollector artifactCollector, DependencyTreeBuilder treeBuilder, SonarIndex index) { this.localRepository = localRepository; this.artifactFactory = artifactFactory; this.artifactMetadataSource = artifactMetadataSource; @@ -79,7 +79,7 @@ public class MavenDependenciesSensor implements Sensor { public boolean endVisit(DependencyNode node) { if (node.getParent() != null && node.getParent() != node) { - saveDependency(node, context); + saveDependency(project, node, context); } return true; } @@ -102,20 +102,20 @@ public class MavenDependenciesSensor implements Sensor { } } - protected void saveDependency(DependencyNode node, SensorContext context) { - Resource from = (node.getParent().getParent() == null) ? index.getProject() : toResource(node.getParent().getArtifact(), context); - Resource to = toResource(node.getArtifact(), context); + protected void saveDependency(final Project project, DependencyNode node, SensorContext context) { + Resource from = (node.getParent().getParent() == null) ? index.getProject() : toResource(project, node.getParent().getArtifact(), context); + Resource to = toResource(project, node.getArtifact(), context); Dependency dependency = new Dependency(from, to); dependency.setUsage(node.getArtifact().getScope()); dependency.setWeight(1); context.saveDependency(dependency); } - protected static Resource toResource(Artifact artifact, SensorContext context) { - Project project = Project.createFromMavenIds(artifact.getGroupId(), artifact.getArtifactId()); - Resource result = context.getResource(project); + protected static Resource toResource(final Project project, Artifact artifact, SensorContext context) { + Project depWithBranch = Project.createFromMavenIds(artifact.getGroupId(), artifact.getArtifactId(), project.getBranch()); + Resource result = context.getResource(depWithBranch); if (result == null || !((Project) result).getAnalysisVersion().equals(artifact.getBaseVersion())) { - Library lib = new Library(project.getKey(), artifact.getBaseVersion()); + Library lib = Library.createFromMavenIds(artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion()); context.saveResource(lib); result = context.getResource(lib); } |