summaryrefslogtreecommitdiffstats
path: root/pom.xml
diff options
context:
space:
mode:
authorramverma <ram.krishna.verma@ericsson.com>2018-08-15 21:28:42 +0100
committerramverma <ram.krishna.verma@ericsson.com>2018-08-15 21:29:27 +0100
commit84beaf8d12f1badc27b4744a4949f8a586370ea9 (patch)
treedf54d6f808601d3f508a86c94ed68da21b8d5796 /pom.xml
parent046b5040ce97e5faf59f3f302331bd9da6e80d02 (diff)
Fix sonar code coverage issue in distribution
The jacoco plugin settings in oparent is for creating coverage report for each sub-module sepeartely. That leads to coverage missing in the report if the test cases & actual classes are in different sub-module. Overiding the setting in distribution to create a consolidated report of all sub-modules in one report. Change-Id: Idf4acd07dbb3694d7bff3c1d94a31a322d7027c5 Issue-ID: POLICY-1035 Signed-off-by: ramverma <ram.krishna.verma@ericsson.com>
Diffstat (limited to 'pom.xml')
-rw-r--r--pom.xml93
1 files changed, 88 insertions, 5 deletions
diff --git a/pom.xml b/pom.xml
index 1107c618..3301082c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,14 +19,14 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.parent</groupId>
<artifactId>integration</artifactId>
<version>2.0.0-SNAPSHOT</version>
- <relativePath/>
+ <relativePath />
</parent>
<groupId>org.onap.policy.distribution</groupId>
@@ -37,6 +37,15 @@
<name>policy-distribution</name>
<description>Code that implements our integration with SDC service distribution API.</description>
+ <properties>
+ <!-- sonar/jacoco overrides -->
+ <!-- Overriding oparent default sonar/jacoco settings Combine all our reports
+ into one file shared across sub-modules -->
+ <sonar.jacoco.reportPath>${project.basedir}/../target/code-coverage/jacoco-ut.exec</sonar.jacoco.reportPath>
+ <sonar.jacoco.itReportPath>${project.basedir}/../target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>
+ <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
+ </properties>
+
<modules>
<module>model</module>
<module>main</module>
@@ -72,9 +81,83 @@
<distributionManagement>
<site>
- <id>ecomp-site</id>
- <url>dav:${nexusproxy}${sitePath}</url>
+ <id>ecomp-site</id>
+ <url>dav:${nexusproxy}${sitePath}</url>
</site>
</distributionManagement>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>pre-unit-test</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ <configuration>
+ <destFile>${sonar.jacoco.reportPath}</destFile>
+ <append>true</append>
+ </configuration>
+ </execution>
+ <execution>
+ <id>post-unit-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ <configuration>
+ <dataFile>${sonar.jacoco.reportPath}</dataFile>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>${jacoco.version}</version>
+ <configuration>
+ <!-- Note: This exclusion list should match <sonar.exclusions> property
+ above -->
+ <excludes>
+ <exclude>**/gen/**</exclude>
+ <exclude>**/generated-sources/**</exclude>
+ <exclude>**/yang-gen/**</exclude>
+ <exclude>**/pax/**</exclude>
+ </excludes>
+ </configuration>
+ <executions>
+ <!-- Prepares the property pointing to the JaCoCo runtime agent which
+ is passed as VM argument when Maven the Surefire plugin is executed. -->
+ <execution>
+ <id>pre-unit-test</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ <configuration>
+ <destFile>${sonar.jacoco.reportPath}</destFile>
+ </configuration>
+ </execution>
+ <!-- Ensures that the code coverage report for unit tests is created
+ after unit tests have been run. -->
+ <execution>
+ <id>post-unit-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ <configuration>
+ <dataFile>${sonar.jacoco.reportPath}</dataFile>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
</project>