Update Sonar/JaCoCo integration 40/88440/4
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 16 Mar 2020 12:30:52 +0000 (13:30 +0100)
committerStephen Kitt <skitt@redhat.com>
Mon, 23 Mar 2020 17:26:14 +0000 (17:26 +0000)
Sonar requires an XML report instead of raw .exec file. Update
configuration to perform reporting.

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

index d3de940ece2b9c4508fc26b244eafbd1edff8678..0d7d54996ae1de7ac8ef474d9f76f0fe64be0252 100644 (file)
@@ -53,6 +53,7 @@
     <!-- JaCoCo configuration, by default tied to Sonar configuration, but can be overridden separately
          to allow projects to report Sonar values from the entire project. -->
     <jacoco.destFile>${project.build.directory}/code-coverage/jacoco.exec</jacoco.destFile>
+    <jacoco.dataFile>${jacoco.destFile}</jacoco.dataFile>
 
     <!-- Default Sonar configuration -->
     <sonar-jacoco-listeners.version>3.8</sonar-jacoco-listeners.version>
             <goals>
               <goal>prepare-agent</goal>
             </goals>
-            <configuration>
-              <destFile>${jacoco.destFile}</destFile>
-            </configuration>
+          </execution>
+          <execution>
+            <id>report</id>
+            <goals>
+              <goal>report</goal>
+            </goals>
           </execution>
         </executions>
       </plugin>
diff --git a/pom.xml b/pom.xml
index ace1061953e966cbc0a03a6740007cb578001405..76139a28e20b0bdc13046ca8c5d45efb23ff9ad2 100644 (file)
--- a/pom.xml
+++ b/pom.xml
                         <artifactId>jacoco-maven-plugin</artifactId>
                         <executions>
                             <execution>
+                                <!-- Step one:
+
+                                    merge all .exec files into a single file into this project's
+                                    ${project.build.directory}/jacoco.exec. Note we are being explicit so as
+                                    to override the odlparent/pom.xml override
+                                -->
                                 <id>merge</id>
                                 <goals>
                                     <goal>merge</goal>
                                     </fileSets>
                                 </configuration>
                             </execution>
+                            <execution>
+                                <!-- Step two:
+
+                                    pick the merged execution file and produce a complete aggregate report,
+                                    including HTML/XML/CSV.
+                                 -->
+                                <id>report</id>
+                                <goals>
+                                    <goal>report-aggregate</goal>
+                                </goals>
+                                <phase>generate-resources</phase>
+                                <configuration>
+                                    <dataFileIncludes>${odl.jacoco.aggregateFile}</dataFileIncludes>
+                                </configuration>
+                            </execution>
                         </executions>
                     </plugin>
                 </plugins>