Add support for aggregate sonar reports 33/78733/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 13 Dec 2018 07:20:18 +0000 (08:20 +0100)
committerRobert Varga <nite@hq.sk>
Thu, 13 Dec 2018 09:03:48 +0000 (09:03 +0000)
This patch teaches the top-level aggregator to combine jacoco
reports for all artifacts, so that sonar can pick it up.

Change-Id: Ie116fcb069b6c384783f0a3f751eb15186dd42ff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
pom.xml

diff --git a/pom.xml b/pom.xml
index 204ba6e37237f11d6b0c65edbacfa3a10039e94d..9e0d9d64ea1f5d5bb0f0c4549308eac0ee786a34 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         </plugins>
     </reporting>
 
-  <profiles>
-    <profile>
-      <id>karaf</id>
-      <activation>
-        <activeByDefault>true</activeByDefault>
-      </activation>
+    <profiles>
+        <profile>
+            <id>karaf</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
 
-      <modules>
-        <module>distribution-karaf</module>
-      </modules>
-    </profile>
-  </profiles>
+            <modules>
+                <module>distribution-karaf</module>
+            </modules>
+        </profile>
+        <profile>
+            <id>sonar-jacoco-aggregate</id>
+            <activation>
+                <property>
+                    <name>odl.jacoco.aggregateFile</name>
+                </property>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.jacoco</groupId>
+                        <artifactId>jacoco-maven-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>merge</id>
+                                <goals>
+                                    <goal>merge</goal>
+                                </goals>
+                                <phase>generate-resources</phase>
+                                <configuration>
+                                    <destFile>${odl.jacoco.aggregateFile}</destFile>
+                                    <fileSets>
+                                        <fileSet>
+                                            <directory>${project.basedir}</directory>
+                                            <includes>
+                                                <include>**/target/code-coverage/*.exec</include>
+                                            </includes>
+                                        </fileSet>
+                                    </fileSets>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
 </project>