From 8632a8cd838273b3946a7b4e79a86e2927b70d8d Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 4 Dec 2014 00:12:45 +0100 Subject: [PATCH] SONARUNNER-125 Fix duplicate properties when parsing complexe sonar-project.properties --- sonar-runner-dist/src/main/java/org/sonar/runner/Conf.java | 2 +- .../src/test/java/org/sonar/runner/ConfTest.java | 4 ++++ .../module1/module11/{ => module111}/placeholder.txt | 0 .../project/module1/module11/module112/placeholder.txt | 0 .../project/sonar-project.properties | 6 ++++++ 5 files changed, 11 insertions(+), 1 deletion(-) rename sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module1/module11/{ => module111}/placeholder.txt (100%) create mode 100644 sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module1/module11/module112/placeholder.txt 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..4066f83 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 @@ -101,7 +101,7 @@ class Conf { moduleProps = loadChildConfigFile(parentBaseDir, moduleProps, module); // the child project may have children as well - loadModulesProperties(moduleProps, projectProps, module + "."); + loadModulesProperties(moduleProps, projectProps, prefix + module + "."); // and finally add this child properties to global props merge(projectProps, prefix, module, moduleProps); } 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 35bbfbf..04292e2 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 @@ -100,8 +100,12 @@ public class ConfTest { assertThat(properties.getProperty("1.sonar.projectName")).isEqualTo("Module 1"); assertThat(properties.getProperty("1.11.sonar.projectName")).isEqualTo("Module 11"); + assertThat(properties.getProperty("1.11.111.sonar.projectName")).isEqualTo("Module 111"); assertThat(properties.getProperty("1.12.sonar.projectName")).isEqualTo("Module 12"); assertThat(properties.getProperty("2.sonar.projectName")).isEqualTo("Module 2"); + + // SONARUNNER-125 + assertThat(properties.getProperty("11.111.sonar.projectName")).isNull(); } @Test 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/module111/placeholder.txt similarity index 100% rename from sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module1/module11/placeholder.txt rename to sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module1/module11/module111/placeholder.txt diff --git a/sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module1/module11/module112/placeholder.txt b/sonar-runner-dist/src/test/resources/org/sonar/runner/ConfTest/shouldSupportDeepModuleConfigurationInRoot/project/module1/module11/module112/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 index 5271377..56eb032 100644 --- 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 @@ -4,6 +4,12 @@ sonar.modules=1,2 1.sonar.modules=11,12 1.11.sonar.projectBaseDir=module11 1.11.sonar.projectName=Module 11 +1.11.sonar.modules=111,112 +1.11.111.sonar.projectBaseDir=module111 +1.11.111.sonar.projectName=Module 111 +1.11.112.sonar.projectBaseDir=module112 +1.11.112.sonar.projectName=Module 112 + 1.12.sonar.projectBaseDir=module12 1.12.sonar.projectName=Module 12 -- 2.39.5