Fix for Jacoco configuration to generate reports for code coverage 24/137724/1
authoradheli.tavares <adheli.tavares@est.tech>
Fri, 19 Apr 2024 12:37:09 +0000 (13:37 +0100)
committeradheli.tavares <adheli.tavares@est.tech>
Fri, 19 Apr 2024 12:43:07 +0000 (13:43 +0100)
Issue-ID: POLICY-4962
Change-Id: I3cb5a6fe2730bb577b310d584ec7e029551f3d3d
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
integration/pom.xml
pom.xml

index b50cc62..20ba7fa 100644 (file)
         <!-- Note Well: For RELEASE/SNAPSHOT always set to the project version -->
         <version.parent.resources>4.1.2-SNAPSHOT</version.parent.resources>
         <version.parent.checkstyle>4.1.2-SNAPSHOT</version.parent.checkstyle>
-        <jacoco.dataFile>${project.basedir}/../target/code-coverage/jacoco-ut.exec</jacoco.dataFile>
-        <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>
-        <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
+        <jacoco.destFile>${project.build.directory}/code-coverage/jacoco-ut.exec</jacoco.destFile>
         <!-- Default Sonar configuration -->
-        <sonar.coverage.jacoco.xmlReportPaths>${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
+        <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
+        <sonar.coverage.jacoco.xmlReportPaths>${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml
+        </sonar.coverage.jacoco.xmlReportPaths>
         <!-- Note: This list should match jacoco-maven-plugin's exclusion list below -->
         <sonar.exclusions>org/drools/**/*,**/gen/**,**/generated-sources/**</sonar.exclusions>
         <repo.npm>https://nexus3.onap.org/repository/npm.public/npm/-/</repo.npm>
                     <artifactId>maven-deploy-plugin</artifactId>
                     <version>3.1.1</version>
                 </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-failsafe-plugin</artifactId>
+                    <version>3.2.5</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.sonarsource.scanner.maven</groupId>
+                    <artifactId>sonar-maven-plugin</artifactId>
+                    <version>${version.sonar}</version>
+                </plugin>
             </plugins>
         </pluginManagement>
         <plugins>
                         <exclude>**/gen/**</exclude>
                         <exclude>**/generated-sources/**</exclude>
                     </excludes>
+                    <output>file</output>
                 </configuration>
                 <executions>
                     <execution>
                             <goal>prepare-agent</goal>
                         </goals>
                         <configuration>
-                            <destFile>${jacoco.dataFile}</destFile>
+                            <destFile>${jacoco.destFile}</destFile>
                             <append>true</append>
+                            <propertyName>surefireArgLine</propertyName>
                         </configuration>
                     </execution>
                     <execution>
                             <goal>report</goal>
                         </goals>
                         <configuration>
-                            <dataFile>${jacoco.dataFile}</dataFile>
-                        </configuration>
-                    </execution>
-                    <execution>
-                        <id>pre-integration-test</id>
-                        <phase>pre-integration-test</phase>
-                        <goals>
-                            <goal>prepare-agent</goal>
-                        </goals>
-                        <configuration>
-                            <skip>true</skip>
-                        </configuration>
-                    </execution>
-                    <execution>
-                        <id>post-integration-test</id>
-                        <phase>post-integration-test</phase>
-                        <goals>
-                            <goal>report</goal>
-                        </goals>
-                        <configuration>
-                            <skip>true</skip>
+                            <dataFile>${jacoco.destFile}</dataFile>
+                            <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
                         </configuration>
                     </execution>
                     <execution>
                         <id>report-aggregate</id>
-                        <phase>prepare-package</phase>
+                        <phase>verify</phase>
                         <goals>
                             <goal>report-aggregate</goal>
                         </goals>
+                        <configuration>
+                            <includeCurrentProject>true</includeCurrentProject>
+                        </configuration>
                     </execution>
                 </executions>
             </plugin>
                     </dependency>
                 </dependencies>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>integration-tests</id>
+                        <goals>
+                            <goal>integration-test</goal>
+                            <goal>verify</goal>
+                        </goals>
+                        <configuration>
+                            <!-- Sets the VM argument line used when integration tests are run. -->
+                            <argLine>${failsafeArgLine}</argLine>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 </project>
diff --git a/pom.xml b/pom.xml
index 18c74a3..ce8f8de 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -67,7 +67,7 @@
                     <artifactId>formatter-maven-plugin</artifactId>
                     <version>2.11.0</version>
                     <configuration>
-                        <configFile>${project.parent.basedir}/onap-java-formatter.xml</configFile>
+                        <configFile>${project.basedir}/onap-java-formatter.xml</configFile>
                     </configuration>
                     <!-- https://code.revelc.net/formatter-maven-plugin/
                          use mvn formatter:format to rewrite source files
                          use mvn spotless:apply to rewrite source files
                          use mvn spotless:check to validate source files -->
                 </plugin>
-                <plugin>
-                    <groupId>org.sonarsource.scanner.maven</groupId>
-                    <artifactId>sonar-maven-plugin</artifactId>
-                    <version>${sonar.scanner.version}</version>
-                </plugin>
             </plugins>
         </pluginManagement>
     </build>