diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-05-05 23:01:54 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-05-06 00:24:06 +0400 |
commit | 804816f9434ba22951a4965155df0837d21f5d22 (patch) | |
tree | 396d1e213dea4e8c4a3c5f4c1745baba73e27198 /sonar-batch | |
parent | be8c67c1396c03bf71cc2fb7770668c54e903e32 (diff) | |
download | sonarqube-804816f9434ba22951a4965155df0837d21f5d22.tar.gz sonarqube-804816f9434ba22951a4965155df0837d21f5d22.zip |
SONAR-2298 Fix bug, when root project not a first one in Maven reactor
This situation shouldn't lead to partial analysis.
Diffstat (limited to 'sonar-batch')
3 files changed, 10 insertions, 7 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/MavenProjectConverter.java b/sonar-batch/src/main/java/org/sonar/batch/MavenProjectConverter.java index 0018b1c35f4..b50f882ba58 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/MavenProjectConverter.java +++ b/sonar-batch/src/main/java/org/sonar/batch/MavenProjectConverter.java @@ -36,7 +36,7 @@ public final class MavenProjectConverter { private MavenProjectConverter() { } - public static ProjectDefinition convert(List<MavenProject> poms) { + public static ProjectDefinition convert(List<MavenProject> poms, MavenProject root) { Map<String, MavenProject> paths = Maps.newHashMap(); // projects by canonical path Map<MavenProject, ProjectDefinition> defs = Maps.newHashMap(); @@ -59,10 +59,13 @@ public final class MavenProjectConverter { throw new SonarException(e); } - return defs.get(poms.get(0)); + return defs.get(root); } - public static ProjectDefinition convert(MavenProject pom) { + /** + * Visibility has been relaxed for tests. + */ + static ProjectDefinition convert(MavenProject pom) { Properties properties = new Properties(); String key = new StringBuilder().append(pom.getGroupId()).append(":").append(pom.getArtifactId()).toString(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java b/sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java index 72a599821e6..54b97fb2b6f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java +++ b/sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java @@ -53,7 +53,7 @@ public class ProjectTree { protected ProjectTree(ProjectBuilder projectBuilder, List<MavenProject> poms) { this.projectBuilder = projectBuilder; definitions = Lists.newArrayList(); - collectProjects(MavenProjectConverter.convert(poms), definitions); + collectProjects(MavenProjectConverter.convert(poms, poms.get(0)), definitions); } /** diff --git a/sonar-batch/src/test/java/org/sonar/batch/MavenProjectConverterTest.java b/sonar-batch/src/test/java/org/sonar/batch/MavenProjectConverterTest.java index c9a2c4124fb..1ee191bebe7 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/MavenProjectConverterTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/MavenProjectConverterTest.java @@ -33,19 +33,19 @@ import java.util.Properties; public class MavenProjectConverterTest { @Test - public void test2() { + public void shouldConvertModules() { MavenProject root = new MavenProject(); root.setFile(new File("/foo/pom.xml")); root.getModules().add("module"); MavenProject module = new MavenProject(); module.setFile(new File("/foo/module/pom.xml")); - ProjectDefinition project = MavenProjectConverter.convert(Arrays.asList(root, module)); + ProjectDefinition project = MavenProjectConverter.convert(Arrays.asList(root, module), root); assertThat(project.getModules().size(), is(1)); } @Test - public void test() { + public void shouldConvertProperties() { MavenProject pom = new MavenProject(); pom.setGroupId("foo"); pom.setArtifactId("bar"); |