]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6514 Unexpected behavior when one module id is 'sonar' 966/head
authorJulien HENRY <julien.henry@sonarsource.com>
Fri, 13 May 2016 07:34:22 +0000 (09:34 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Fri, 13 May 2016 11:43:20 +0000 (13:43 +0200)
sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java
sonar-scanner-engine/src/test/java/org/sonar/batch/scan/ProjectReactorBuilderTest.java
sonar-scanner-engine/src/test/resources/org/sonar/batch/scan/ProjectReactorBuilderTest/multi-module-sonar-module/sonar-project.properties [new file with mode: 0644]

index 2d7e453cfaf83190893c856f98a98d93c3c514f3..cd779df9e8eef296f072b1d04e08e5cae21ce85d 100644 (file)
@@ -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);
     }
index d1a61853ef23a8cdc78f22993d1f77b0d063999b..c550bb3ba3916dc663c3a6acae810a84f3f025c6 100644 (file)
@@ -101,6 +101,14 @@ public class ProjectReactorBuilderTest {
     loadProjectDefinition("multi-module-duplicate-id");
   }
 
+  @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 (file)
index 0000000..3f29709
--- /dev/null
@@ -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