aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/MavenProjectConverter.java9
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/MavenProjectConverterTest.java6
-rw-r--r--sonar-core-maven-plugin/src/main/java/org/sonar/maven2/BatchMojo.java2
-rw-r--r--sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java2
-rw-r--r--sonar-maven3-plugin/src/main/java/org/sonar/maven3/SonarMojo.java2
6 files changed, 13 insertions, 10 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");
diff --git a/sonar-core-maven-plugin/src/main/java/org/sonar/maven2/BatchMojo.java b/sonar-core-maven-plugin/src/main/java/org/sonar/maven2/BatchMojo.java
index f979a24944d..02578c37b0a 100644
--- a/sonar-core-maven-plugin/src/main/java/org/sonar/maven2/BatchMojo.java
+++ b/sonar-core-maven-plugin/src/main/java/org/sonar/maven2/BatchMojo.java
@@ -145,7 +145,7 @@ public final class BatchMojo extends AbstractMojo {
}
private void executeBatch() throws MojoExecutionException {
- ProjectDefinition def = MavenProjectConverter.convert(session.getSortedProjects());
+ ProjectDefinition def = MavenProjectConverter.convert(session.getSortedProjects(), project);
Reactor reactor = new Reactor(def);
Batch batch = new Batch(getInitialConfiguration(), reactor, session, project,
diff --git a/sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java b/sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java
index eb57053ba8a..0f84702b9c9 100644
--- a/sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java
+++ b/sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java
@@ -145,7 +145,7 @@ public final class SonarMojo extends AbstractMojo {
}
private void executeBatch() throws MojoExecutionException {
- ProjectDefinition def = MavenProjectConverter.convert(session.getSortedProjects());
+ ProjectDefinition def = MavenProjectConverter.convert(session.getSortedProjects(), project);
Reactor reactor = new Reactor(def);
Batch batch = new Batch(getInitialConfiguration(),
diff --git a/sonar-maven3-plugin/src/main/java/org/sonar/maven3/SonarMojo.java b/sonar-maven3-plugin/src/main/java/org/sonar/maven3/SonarMojo.java
index 7bb5e3e5f69..82f0847f2de 100644
--- a/sonar-maven3-plugin/src/main/java/org/sonar/maven3/SonarMojo.java
+++ b/sonar-maven3-plugin/src/main/java/org/sonar/maven3/SonarMojo.java
@@ -138,7 +138,7 @@ public final class SonarMojo extends AbstractMojo {
}
private void executeBatch() throws MojoExecutionException {
- ProjectDefinition def = MavenProjectConverter.convert(session.getSortedProjects());
+ ProjectDefinition def = MavenProjectConverter.convert(session.getSortedProjects(), project);
Reactor reactor = new Reactor(def);
Batch batch = new Batch(getInitialConfiguration(),