From: Julien HENRY Date: Thu, 27 Nov 2014 13:37:45 +0000 (+0100) Subject: SONARUNNER-124 Unable to configure multi-module project with more than 2 levels in... X-Git-Tag: 2.5-rc1~99 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=284f5c685bbc5022b9f333d6badd4529784a41b3;p=sonar-scanner-cli.git SONARUNNER-124 Unable to configure multi-module project with more than 2 levels in a single file --- diff --git a/sonar-runner-dist/src/main/java/org/sonar/runner/Conf.java b/sonar-runner-dist/src/main/java/org/sonar/runner/Conf.java index 6ba9d72..f6301ae 100644 --- a/sonar-runner-dist/src/main/java/org/sonar/runner/Conf.java +++ b/sonar-runner-dist/src/main/java/org/sonar/runner/Conf.java @@ -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 diff --git a/sonar-runner-dist/src/test/java/org/sonar/runner/ConfTest.java b/sonar-runner-dist/src/test/java/org/sonar/runner/ConfTest.java index 162c5f7..946d843 100644 --- a/sonar-runner-dist/src/test/java/org/sonar/runner/ConfTest.java +++ b/sonar-runner-dist/src/test/java/org/sonar/runner/ConfTest.java @@ -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 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 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 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 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 index 0000000..33221bf --- /dev/null +++ b/sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/sonar-project.properties @@ -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