diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2016-05-13 09:34:22 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2016-05-13 13:43:20 +0200 |
commit | cadc0c3e861eebce78bcdbf99c30c416ce9c42d2 (patch) | |
tree | 288a4f1ac7d1d153535906e40c1a01556e8e9d7b /sonar-scanner-engine | |
parent | aa98472baece8f11b72600cf78f2b2f1234cd103 (diff) | |
download | sonarqube-cadc0c3e861eebce78bcdbf99c30c416ce9c42d2.tar.gz sonarqube-cadc0c3e861eebce78bcdbf99c30c416ce9c42d2.zip |
SONAR-6514 Unexpected behavior when one module id is 'sonar'
Diffstat (limited to 'sonar-scanner-engine')
3 files changed, 27 insertions, 1 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java index 2d7e453cfaf..cd779df9e8e 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java @@ -154,13 +154,16 @@ public class ProjectReactorBuilder { } } String[] moduleIds = getListFromProperty(currentModuleProperties, PROPERTY_MODULES); - // Sort module by reverse lexicographic order to avoid issue when one module id is a prefix of another one + // Sort modules by reverse lexicographic order to avoid issue when one module id is a prefix of another one Arrays.sort(moduleIds); ArrayUtils.reverse(moduleIds); propertiesByModuleIdPath.put(currentModuleIdPath, currentModuleProperties); for (String moduleId : moduleIds) { + if ("sonar".equals(moduleId)) { + throw MessageException.of("'sonar' is not a valid module id. Please check property '" + PROPERTY_MODULES + "'."); + } String subModuleIdPath = currentModuleIdPath.isEmpty() ? moduleId : (currentModuleIdPath + "." + moduleId); extractPropertiesByModule(propertiesByModuleIdPath, moduleId, subModuleIdPath, currentModuleProperties); } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java index d1a61853ef2..c550bb3ba39 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java @@ -102,6 +102,14 @@ public class ProjectReactorBuilderTest { } @Test + public void sonarModuleIdIsForbidden() { + thrown.expect(MessageException.class); + thrown.expectMessage("'sonar' is not a valid module id. Please check property 'sonar.modules'."); + + loadProjectDefinition("multi-module-sonar-module"); + } + + @Test public void modulesRepeatedIds() { ProjectDefinition rootProject = loadProjectDefinition("multi-module-repeated-id"); diff --git a/sonar-scanner-engine/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-sonar-module/sonar-project.properties b/sonar-scanner-engine/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-sonar-module/sonar-project.properties new file mode 100644 index 00000000000..3f297090471 --- /dev/null +++ b/sonar-scanner-engine/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-sonar-module/sonar-project.properties @@ -0,0 +1,15 @@ +sonar.projectKey=com.foo.project +sonar.projectName=Foo Project +sonar.projectVersion=1.0-SNAPSHOT +sonar.projectDescription=Description of Foo Project + +sonar.sources=sources +sonar.tests=tests +sonar.binaries=target/classes + +sonar.modules=module1,sonar + +module1.sonar.sources=src + +# Unable to know to which module belong this property +sonar.sonar.sources=foo |