]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7258 The project version should be optional 1195/head
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Tue, 30 Aug 2016 12:42:49 +0000 (14:42 +0200)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Wed, 31 Aug 2016 09:30:25 +0000 (11:30 +0200)
35 files changed:
it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a1/sonar-project.properties [new file with mode: 0644]
it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo [new file with mode: 0644]
it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo.measures [new file with mode: 0644]
it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a2/sonar-project.properties [new file with mode: 0644]
it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo [new file with mode: 0644]
it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo.measures [new file with mode: 0644]
it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/sonar-project.properties [new file with mode: 0644]
it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo [new file with mode: 0644]
it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo.measures [new file with mode: 0644]
it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/module_b2/sonar-project.properties [new file with mode: 0644]
it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/module_b2/src/main/xoo/com/sonar/it/samples/modules/b2/HelloB2.xoo [new file with mode: 0644]
it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/module_b2/src/main/xoo/com/sonar/it/samples/modules/b2/HelloB2.xoo.measures [new file with mode: 0644]
it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/sonar-project.properties [new file with mode: 0644]
it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/sonar-project.properties [new file with mode: 0644]
it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a1/sonar-project.properties [deleted file]
it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo [deleted file]
it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo.measures [deleted file]
it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a2/sonar-project.properties [deleted file]
it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo [deleted file]
it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo.measures [deleted file]
it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/sonar-project.properties [deleted file]
it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo [deleted file]
it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo.measures [deleted file]
it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/module_b2/sonar-project.properties [deleted file]
it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/module_b2/src/main/xoo/com/sonar/it/samples/modules/b2/HelloB2.xoo [deleted file]
it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/module_b2/src/main/xoo/com/sonar/it/samples/modules/b2/HelloB2.xoo.measures [deleted file]
it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/sonar-project.properties [deleted file]
it/it-projects/shared/xoo-multi-module-sample-without-project-name/sonar-project.properties [deleted file]
it/it-tests/src/test/java/it/analysis/BatchTest.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectBuilderTest.java
sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectDefinitionTest.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorBuilder.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java

diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a1/sonar-project.properties b/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a1/sonar-project.properties
new file mode 100644 (file)
index 0000000..a081a0e
--- /dev/null
@@ -0,0 +1 @@
+sonar.projectName=Sub-module A1
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo b/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo
new file mode 100644 (file)
index 0000000..74d29a4
--- /dev/null
@@ -0,0 +1,16 @@
+package com.sonar.it.samples.modules.a1;
+
+public class HelloA1 {
+       private int i;
+       private HelloA1() {
+               
+       }
+       
+       public void hello() {
+               System.out.println("hello" + " xoo");
+       }
+       
+       protected String getHello() {
+               return "hello";
+       }
+}
\ No newline at end of file
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo.measures b/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo.measures
new file mode 100644 (file)
index 0000000..7812e41
--- /dev/null
@@ -0,0 +1,2 @@
+ncloc:12
+classes:1
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a2/sonar-project.properties b/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a2/sonar-project.properties
new file mode 100644 (file)
index 0000000..fcedab8
--- /dev/null
@@ -0,0 +1 @@
+sonar.projectName=Sub-module A2
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo b/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo
new file mode 100644 (file)
index 0000000..796d90c
--- /dev/null
@@ -0,0 +1,20 @@
+package com.sonar.it.samples.modules.a2;
+
+public class HelloA2 {
+
+       public HelloA2(int i) {
+               int j = i++;
+       }
+
+       public void hello() {
+               System.out.println("hello" + " xoo");
+  }
+
+       private String myMethod() {
+               if (foo == bar) {
+                       return "hello";
+               } else {
+                       throw new IllegalStateException();
+               }
+       }
+}
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo.measures b/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo.measures
new file mode 100644 (file)
index 0000000..63df5ad
--- /dev/null
@@ -0,0 +1,2 @@
+ncloc:15
+classes:1
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/sonar-project.properties b/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_a/sonar-project.properties
new file mode 100644 (file)
index 0000000..7e6ca90
--- /dev/null
@@ -0,0 +1,4 @@
+sonar.projectKey=module_a
+sonar.projectName=Module A
+sonar.modules=module_a1,module_a2
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo b/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo
new file mode 100644 (file)
index 0000000..b83c3af
--- /dev/null
@@ -0,0 +1,12 @@
+package com.sonar.it.samples.modules.b1;
+
+public class HelloB1 {
+       private int i;
+       private HelloB1() {
+               
+       }
+       
+       public void hello() {
+               System.out.println("hello" + " world");
+       }
+}
\ No newline at end of file
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo.measures b/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo.measures
new file mode 100644 (file)
index 0000000..3947d3b
--- /dev/null
@@ -0,0 +1,2 @@
+ncloc:12
+classes:1
\ No newline at end of file
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/module_b2/sonar-project.properties b/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/module_b2/sonar-project.properties
new file mode 100644 (file)
index 0000000..e597dab
--- /dev/null
@@ -0,0 +1 @@
+sonar.projectName=Sub-module B2
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/module_b2/src/main/xoo/com/sonar/it/samples/modules/b2/HelloB2.xoo b/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/module_b2/src/main/xoo/com/sonar/it/samples/modules/b2/HelloB2.xoo
new file mode 100644 (file)
index 0000000..20b8bb3
--- /dev/null
@@ -0,0 +1,12 @@
+package com.sonar.it.samples.modules.b2;
+
+public class HelloB2 {
+       private int i;
+       private HelloB2() {
+               
+       }
+       
+       public void hello() {
+               System.out.println("hello" + " world");
+       }
+}
\ No newline at end of file
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/module_b2/src/main/xoo/com/sonar/it/samples/modules/b2/HelloB2.xoo.measures b/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/module_b2/src/main/xoo/com/sonar/it/samples/modules/b2/HelloB2.xoo.measures
new file mode 100644 (file)
index 0000000..3947d3b
--- /dev/null
@@ -0,0 +1,2 @@
+ncloc:12
+classes:1
\ No newline at end of file
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/sonar-project.properties b/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/module_b/sonar-project.properties
new file mode 100644 (file)
index 0000000..7bc39b4
--- /dev/null
@@ -0,0 +1,3 @@
+sonar.projectKey=module_b
+sonar.modules=module_b1,module_b2
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/sonar-project.properties b/it/it-projects/shared/xoo-multi-module-sample-without-project-name-version/sonar-project.properties
new file mode 100644 (file)
index 0000000..0743049
--- /dev/null
@@ -0,0 +1,10 @@
+# Root project information
+sonar.projectKey=com.sonarsource.it.samples:multi-modules-sample
+
+sonar.language=xoo
+# Some properties that will be inherited by the modules
+sonar.sources=src/main/xoo
+# List of the module identifiers
+sonar.modules=module_a,module_b
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a1/sonar-project.properties b/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a1/sonar-project.properties
deleted file mode 100644 (file)
index a081a0e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-sonar.projectName=Sub-module A1
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo b/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo
deleted file mode 100644 (file)
index 74d29a4..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.sonar.it.samples.modules.a1;
-
-public class HelloA1 {
-       private int i;
-       private HelloA1() {
-               
-       }
-       
-       public void hello() {
-               System.out.println("hello" + " xoo");
-       }
-       
-       protected String getHello() {
-               return "hello";
-       }
-}
\ No newline at end of file
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo.measures b/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo.measures
deleted file mode 100644 (file)
index 7812e41..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-ncloc:12
-classes:1
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a2/sonar-project.properties b/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a2/sonar-project.properties
deleted file mode 100644 (file)
index fcedab8..0000000
+++ /dev/null
@@ -1 +0,0 @@
-sonar.projectName=Sub-module A2
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo b/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo
deleted file mode 100644 (file)
index 796d90c..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.sonar.it.samples.modules.a2;
-
-public class HelloA2 {
-
-       public HelloA2(int i) {
-               int j = i++;
-       }
-
-       public void hello() {
-               System.out.println("hello" + " xoo");
-  }
-
-       private String myMethod() {
-               if (foo == bar) {
-                       return "hello";
-               } else {
-                       throw new IllegalStateException();
-               }
-       }
-}
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo.measures b/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo.measures
deleted file mode 100644 (file)
index 63df5ad..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-ncloc:15
-classes:1
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/sonar-project.properties b/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_a/sonar-project.properties
deleted file mode 100644 (file)
index 7e6ca90..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-sonar.projectKey=module_a
-sonar.projectName=Module A
-sonar.modules=module_a1,module_a2
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo b/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo
deleted file mode 100644 (file)
index b83c3af..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.sonar.it.samples.modules.b1;
-
-public class HelloB1 {
-       private int i;
-       private HelloB1() {
-               
-       }
-       
-       public void hello() {
-               System.out.println("hello" + " world");
-       }
-}
\ No newline at end of file
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo.measures b/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo.measures
deleted file mode 100644 (file)
index 3947d3b..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-ncloc:12
-classes:1
\ No newline at end of file
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/module_b2/sonar-project.properties b/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/module_b2/sonar-project.properties
deleted file mode 100644 (file)
index e597dab..0000000
+++ /dev/null
@@ -1 +0,0 @@
-sonar.projectName=Sub-module B2
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/module_b2/src/main/xoo/com/sonar/it/samples/modules/b2/HelloB2.xoo b/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/module_b2/src/main/xoo/com/sonar/it/samples/modules/b2/HelloB2.xoo
deleted file mode 100644 (file)
index 20b8bb3..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.sonar.it.samples.modules.b2;
-
-public class HelloB2 {
-       private int i;
-       private HelloB2() {
-               
-       }
-       
-       public void hello() {
-               System.out.println("hello" + " world");
-       }
-}
\ No newline at end of file
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/module_b2/src/main/xoo/com/sonar/it/samples/modules/b2/HelloB2.xoo.measures b/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/module_b2/src/main/xoo/com/sonar/it/samples/modules/b2/HelloB2.xoo.measures
deleted file mode 100644 (file)
index 3947d3b..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-ncloc:12
-classes:1
\ No newline at end of file
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/sonar-project.properties b/it/it-projects/shared/xoo-multi-module-sample-without-project-name/module_b/sonar-project.properties
deleted file mode 100644 (file)
index 7bc39b4..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-sonar.projectKey=module_b
-sonar.modules=module_b1,module_b2
diff --git a/it/it-projects/shared/xoo-multi-module-sample-without-project-name/sonar-project.properties b/it/it-projects/shared/xoo-multi-module-sample-without-project-name/sonar-project.properties
deleted file mode 100644 (file)
index 9c22998..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-# Root project information
-sonar.projectKey=com.sonarsource.it.samples:multi-modules-sample
-sonar.projectVersion=1.0-SNAPSHOT
-
-sonar.language=xoo
-# Some properties that will be inherited by the modules
-sonar.sources=src/main/xoo
-# List of the module identifiers
-sonar.modules=module_a,module_b
index 62c5a4b6ab88c94becd505a49fbda4572e9ba2ef..194c2b74f07f295ac62f0be2761d1d66323279ff 100644 (file)
@@ -193,45 +193,50 @@ public class BatchTest {
   }
 
   @Test
-  public void should_create_project_without_name() {
+  public void should_create_project_without_name_version() {
     //some of the sub-modules have a name defined, others don't
-    BuildResult buildResult = scan("shared/xoo-multi-module-sample-without-project-name");
+    BuildResult buildResult = scan("shared/xoo-multi-module-sample-without-project-name-version");
     assertThat(buildResult.isSuccess()).isTrue();
 
-    assertProjectName("com.sonarsource.it.samples:multi-modules-sample", "com.sonarsource.it.samples:multi-modules-sample");
+    assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample", "com.sonarsource.it.samples:multi-modules-sample", "not provided");
     
-    assertProjectName("com.sonarsource.it.samples:multi-modules-sample:module_b", "module_b");
-    assertProjectName("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b1", "module_b1");
-    assertProjectName("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b2", "Sub-module B2");
+    assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b", "module_b", "not provided");
+    assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b1", "module_b1", "not provided");
+    assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b2", "Sub-module B2", "not provided");
     
-    assertProjectName("com.sonarsource.it.samples:multi-modules-sample:module_a", "Module A");
-    assertProjectName("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1", "Sub-module A1");
-    assertProjectName("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a2", "Sub-module A2");
-
+    assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a", "Module A", "not provided");
+    assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1", "Sub-module A1", "not provided");
+    assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a2", "Sub-module A2", "not provided");
   }
   
   @Test
-  public void should_analyze_project_without_name() {
+  public void should_analyze_project_without_name_version() {
     orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "My project name");
-    BuildResult buildResult = scan("shared/xoo-multi-module-sample-without-project-name");
+    BuildResult buildResult = scan("shared/xoo-multi-module-sample-without-project-name-version",
+      "sonar.projectName", "My project name",
+      "sonar.projectVersion", "1.0");
+    assertThat(buildResult.isSuccess()).isTrue();
+    
+    buildResult = scan("shared/xoo-multi-module-sample-without-project-name-version");
     assertThat(buildResult.isSuccess()).isTrue();
 
-    assertProjectName("com.sonarsource.it.samples:multi-modules-sample", "My project name");
+    assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample", "My project name", "1.0");
     
-    assertProjectName("com.sonarsource.it.samples:multi-modules-sample:module_b", "module_b");
-    assertProjectName("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b1", "module_b1");
-    assertProjectName("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b2", "Sub-module B2");
+    assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b", "module_b", "1.0");
+    assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b1", "module_b1", "1.0");
+    assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_b:module_b2", "Sub-module B2", "1.0");
     
-    assertProjectName("com.sonarsource.it.samples:multi-modules-sample:module_a", "Module A");
-    assertProjectName("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1", "Sub-module A1");
-    assertProjectName("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a2", "Sub-module A2");
+    assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a", "Module A", "1.0");
+    assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1", "Sub-module A1", "1.0");
+    assertNameAndVersion("com.sonarsource.it.samples:multi-modules-sample:module_a:module_a2", "Sub-module A2", "1.0");
   }
   
-  private void assertProjectName(String projectKey, String expectedProjectName) {
-    ShowWsRequest req = new ShowWsRequest();
-    req.setKey(projectKey);
-    ShowWsResponse response = ItUtils.newWsClient(orchestrator).components().show(req);
-    assertThat(response.getComponent().getName()).isEqualTo(expectedProjectName);
+  private void assertNameAndVersion(String projectKey, String expectedProjectName, String expectedProjectVersion) {
+    // new WS Client with api/components doesn't return the project version, so use the old one
+    Resource resource = orchestrator.getServer().getAdminWsClient().find(new ResourceQuery(projectKey));
+    assertThat(resource.getName()).isEqualTo(expectedProjectName);
+    assertThat(resource.getVersion()).isEqualTo(expectedProjectVersion);
+
   }
 
   @Test
index 33c23cd3f7e5019436bf9e56c9a9381119eb4c3b..95953da2422250e880f6e0a839f5cf0d6a5b0765 100644 (file)
@@ -186,9 +186,18 @@ public class ProjectDefinition {
     }
     return null;
   }
+  
+  @CheckForNull
+  public String getOriginalVersion() {
+    return properties.get(CoreProperties.PROJECT_VERSION_PROPERTY);
+  }
 
   public String getVersion() {
-    return properties.get(CoreProperties.PROJECT_VERSION_PROPERTY);
+    String version = properties.get(CoreProperties.PROJECT_VERSION_PROPERTY);
+    if (StringUtils.isBlank(version)) {
+      version = "not provided";
+    }
+    return version;
   }
   
   @CheckForNull
index c3f2efde1513aff177d8c8f8b08f40bdd2e33aeb..6fbf0bdfdc7bf93d95c2b4d38cca65c133652a6e 100644 (file)
@@ -68,7 +68,7 @@ public class ProjectBuilderTest {
       subProject.setBaseDir(baseDir);
       subProject.setWorkDir(new File(baseDir, "target/.sonar"));
       subProject.setKey("groupId:parentProjectId");
-      subProject.setVersion(root.getVersion());
+      subProject.setVersion(root.getOriginalVersion());
       subProject.setName("Sub Project");
       subProject.setSources("src");
       root.addSubProject(subProject);
index 2db3cef3a860c8a935ac013184f4a90b61249bde..9cee607615c5a2586fa5cda1ac9017f79e00beeb 100644 (file)
@@ -41,6 +41,14 @@ public class ProjectDefinitionTest {
     assertThat(def.getVersion()).isEqualTo("2.0-SNAPSHOT");
   }
 
+  @Test
+  public void shouldSupportNoVersion() {
+    ProjectDefinition def = ProjectDefinition.create();
+    def.setVersion(null);
+    assertThat(def.getVersion()).isEqualTo("not provided");
+    assertThat(def.getOriginalVersion()).isEqualTo("");
+  }
+
   @Test
   public void shouldSetOptionalFields() {
     ProjectDefinition def = ProjectDefinition.create();
index 77f36cc7bd79ff70e4ef44a9dd0a6d1c893bfe0d..1f5238b8a8d3df84b7e96496f83ab28e399b6817 100644 (file)
@@ -109,13 +109,19 @@ public class ComponentsPublisher implements ReportPublisherStep {
     if (c.isProjectOrModule()) {
       ProjectDefinition def = reactor.getProjectDefinition(c.key());
       String version = getVersion(def);
-      builder.setVersion(version);
+      if(version != null) {
+        builder.setVersion(version);
+      }
     }
   }
 
   private static String getVersion(ProjectDefinition def) {
-    String version = def.getVersion();
-    return StringUtils.isNotBlank(version) ? version : getVersion(def.getParent());
+    String version = def.getOriginalVersion();
+    if(StringUtils.isNotBlank(version)) {
+      return version;
+    }
+    
+    return def.getParent() != null ? getVersion(def.getParent()) : null;
   }
 
   private void writeLinks(BatchComponent c, ScannerReport.Component.Builder builder) {
index 19bd48ad076b7337dcdd87b71290bca43ba3708f..f3da9c379768b06f7360b646377ef935cd2ede00 100644 (file)
@@ -89,15 +89,13 @@ public class ProjectReactorBuilder {
    * Array of all mandatory properties required for a project without child.
    */
   private static final String[] MANDATORY_PROPERTIES_FOR_SIMPLE_PROJECT = {
-    PROPERTY_PROJECT_BASEDIR, CoreProperties.PROJECT_KEY_PROPERTY,
-    CoreProperties.PROJECT_VERSION_PROPERTY, PROPERTY_SOURCES
+    PROPERTY_PROJECT_BASEDIR, CoreProperties.PROJECT_KEY_PROPERTY, PROPERTY_SOURCES
   };
 
   /**
    * Array of all mandatory properties required for a project with children.
    */
-  private static final String[] MANDATORY_PROPERTIES_FOR_MULTIMODULE_PROJECT = {PROPERTY_PROJECT_BASEDIR, CoreProperties.PROJECT_KEY_PROPERTY,
-    CoreProperties.PROJECT_VERSION_PROPERTY};
+  private static final String[] MANDATORY_PROPERTIES_FOR_MULTIMODULE_PROJECT = {PROPERTY_PROJECT_BASEDIR, CoreProperties.PROJECT_KEY_PROPERTY};
 
   /**
    * Array of all mandatory properties required for a child project before its properties get merged with its parent ones.
index 7929b0ebe4ff5c1aee1915e73049accbfb4cd086..0f6eb6dbdccc0235d19e66700123c239b1782538 100644 (file)
@@ -20,6 +20,8 @@
 package org.sonar.scanner.report;
 
 import java.io.File;
+import java.io.IOException;
+
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
@@ -116,6 +118,73 @@ public class ComponentsPublisherTest {
     assertThat(module1Protobuf.getDescription()).isEqualTo("Module description");
     assertThat(module1Protobuf.getVersion()).isEqualTo("1.0");
   }
+  
+  @Test
+  public void add_components_without_version_and_name() throws IOException {
+    ProjectDefinition rootDef = ProjectDefinition.create().setKey("foo");
+    Project root = new Project("foo").setDescription("Root description")
+      .setAnalysisDate(DateUtils.parseDate(("2012-12-12")));
+    root.setId(1).setUuid("PROJECT_UUID");
+    resourceCache.add(root, null).setInputComponent(new DefaultInputModule("foo"));
+
+    Project module1 = new Project("module1").setDescription("Module description");
+    module1.setParent(root);
+    module1.setId(2).setUuid("MODULE_UUID");
+    resourceCache.add(module1, root).setInputComponent(new DefaultInputModule("module1"));
+    rootDef.addSubProject(ProjectDefinition.create().setKey("module1"));
+
+    Directory dir = Directory.create("src");
+    dir.setEffectiveKey("module1:src");
+    dir.setId(3).setUuid("DIR_UUID");
+    resourceCache.add(dir, module1).setInputComponent(new DefaultInputDir("foo", "src"));
+
+    org.sonar.api.resources.File file = org.sonar.api.resources.File.create("src/Foo.java", FakeJava.INSTANCE, false);
+    file.setEffectiveKey("module1:src/Foo.java");
+    file.setId(4).setUuid("FILE_UUID");
+    resourceCache.add(file, dir).setInputComponent(new DefaultInputFile("module1", "src/Foo.java").setLines(2));
+
+    org.sonar.api.resources.File fileWithoutLang = org.sonar.api.resources.File.create("src/make", null, false);
+    fileWithoutLang.setEffectiveKey("module1:src/make");
+    fileWithoutLang.setId(5).setUuid("FILE_WITHOUT_LANG_UUID");
+    resourceCache.add(fileWithoutLang, dir).setInputComponent(new DefaultInputFile("module1", "src/make").setLines(10));
+
+    org.sonar.api.resources.File testFile = org.sonar.api.resources.File.create("test/FooTest.java", FakeJava.INSTANCE, true);
+    testFile.setEffectiveKey("module1:test/FooTest.java");
+    testFile.setId(6).setUuid("TEST_FILE_UUID");
+    resourceCache.add(testFile, dir).setInputComponent(new DefaultInputFile("module1", "test/FooTest.java").setLines(4));
+
+    ImmutableProjectReactor reactor = new ImmutableProjectReactor(rootDef);
+
+    ComponentsPublisher publisher = new ComponentsPublisher(reactor, resourceCache);
+
+    File outputDir = temp.newFolder();
+    ScannerReportWriter writer = new ScannerReportWriter(outputDir);
+    publisher.publish(writer);
+
+    assertThat(writer.hasComponentData(FileStructure.Domain.COMPONENT, 1)).isTrue();
+    assertThat(writer.hasComponentData(FileStructure.Domain.COMPONENT, 2)).isTrue();
+    assertThat(writer.hasComponentData(FileStructure.Domain.COMPONENT, 3)).isTrue();
+    assertThat(writer.hasComponentData(FileStructure.Domain.COMPONENT, 4)).isTrue();
+    assertThat(writer.hasComponentData(FileStructure.Domain.COMPONENT, 5)).isTrue();
+    assertThat(writer.hasComponentData(FileStructure.Domain.COMPONENT, 6)).isTrue();
+
+    // no such reference
+    assertThat(writer.hasComponentData(FileStructure.Domain.COMPONENT, 7)).isFalse();
+
+    ScannerReportReader reader = new ScannerReportReader(outputDir);
+    Component rootProtobuf = reader.readComponent(1);
+    assertThat(rootProtobuf.getKey()).isEqualTo("foo");
+    assertThat(rootProtobuf.getName()).isEqualTo("");
+    assertThat(rootProtobuf.getDescription()).isEqualTo("Root description");
+    assertThat(rootProtobuf.getVersion()).isEqualTo("");
+    assertThat(rootProtobuf.getLinkCount()).isEqualTo(0);
+
+    Component module1Protobuf = reader.readComponent(2);
+    assertThat(module1Protobuf.getKey()).isEqualTo("module1");
+    assertThat(module1Protobuf.getName()).isEqualTo("");
+    assertThat(module1Protobuf.getDescription()).isEqualTo("Module description");
+    assertThat(module1Protobuf.getVersion()).isEqualTo("");
+  }
 
   @Test
   public void add_components_with_links_and_branch() throws Exception {