]> source.dussan.org Git - sonar-scanner-cli.git/commitdiff
SONARUNNER-124 Unable to configure multi-module project with more than 2 levels in...
authorJulien HENRY <julien.henry@sonarsource.com>
Thu, 27 Nov 2014 13:37:45 +0000 (14:37 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Thu, 27 Nov 2014 13:37:45 +0000 (14:37 +0100)
sonar-runner-dist/src/main/java/org/sonar/runner/Conf.java
sonar-runner-dist/src/test/java/org/sonar/runner/ConfTest.java
sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module1/module11/placeholder.txt [new file with mode: 0644]
sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module1/module12/placeholder.txt [new file with mode: 0644]
sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module2/module21/placeholder.txt [new file with mode: 0644]
sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module2/module22/placeholder.txt [new file with mode: 0644]
sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/sonar-project.properties [new file with mode: 0644]

index 6ba9d723b445209fd1177a79eb560ebc6b3ae4a6..f6301aee44504b4a5ebf11331c84d90986ef5fb4 100644 (file)
@@ -97,7 +97,7 @@ class Conf {
     File parentBaseDir = new File(parentProps.getProperty(PROPERTY_PROJECT_BASEDIR));
     if (parentProps.containsKey(PROPERTY_MODULES)) {
       for (String module : getListFromProperty(parentProps, PROPERTY_MODULES)) {
-        Properties moduleProps = extractModuleProperties(module, parentProps);
+        Properties moduleProps = extractModuleProperties(module, projectProps);
         moduleProps = loadChildConfigFile(parentBaseDir, moduleProps, module);
 
         // the child project may have children as well
index 162c5f71c8966c0f7f84556f7da63ea947943c8e..946d8431e483c0972cb39914add9389a2619ad64 100644 (file)
@@ -91,6 +91,19 @@ public class ConfTest {
     assertThat(properties.getProperty("module2.sonar.projectName")).isEqualTo("Module 2");
   }
 
+  @Test
+  public void shouldSupportDeepModuleConfigurationInRoot() throws Exception {
+    File projectHome = new File(getClass().getResource("/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project").toURI());
+    args.setProperty("project.home", projectHome.getCanonicalPath());
+
+    Properties properties = conf.properties();
+
+    assertThat(properties.getProperty("1.sonar.projectName")).isEqualTo("Module 1");
+    assertThat(properties.getProperty("11.sonar.projectName")).isEqualTo("Module 11");
+    assertThat(properties.getProperty("12.sonar.projectName")).isEqualTo("Module 12");
+    assertThat(properties.getProperty("2.sonar.projectName")).isEqualTo("Module 2");
+  }
+
   @Test
   public void shouldLoadModuleConfigurationOverrideBasedir() throws Exception {
     File projectHome = new File(getClass().getResource("/org/sonar/runner/ConfTest/shouldLoadModuleConfigurationOverrideBasedir/project").toURI());
diff --git a/sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module1/module11/placeholder.txt b/sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module1/module11/placeholder.txt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module1/module12/placeholder.txt b/sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module1/module12/placeholder.txt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module2/module21/placeholder.txt b/sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module2/module21/placeholder.txt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module2/module22/placeholder.txt b/sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module2/module22/placeholder.txt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/sonar-project.properties b/sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/sonar-project.properties
new file mode 100644 (file)
index 0000000..33221bf
--- /dev/null
@@ -0,0 +1,11 @@
+sonar.modules=1,2
+1.sonar.projectName=Module 1
+1.sonar.projectBaseDir=module1
+1.sonar.modules=11,12
+11.sonar.projectBaseDir=module11
+11.sonar.projectName=Module 11
+12.sonar.projectBaseDir=module12
+12.sonar.projectName=Module 12
+
+2.sonar.projectName=Module 2
+2.sonar.projectBaseDir=module2
\ No newline at end of file