Fix code coverage for sonar
[cps.git] / cps-parent / pom.xml
old mode 100644 (file)
new mode 100755 (executable)
index 89f9629..125c843
         <base.image>openjdk:11-jre-slim</base.image>
         <java.version>11</java.version>
         <jib-maven-plugin.version>2.6.0</jib-maven-plugin.version>
-        <minimum-coverage>0.20</minimum-coverage>
+        <minimum-coverage>0.76</minimum-coverage>
         <nexusproxy>https://nexus.onap.org</nexusproxy>
         <oparent.version>3.1.0</oparent.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
         <repository.name>nexus3.onap.org:10001/onap/cps-service</repository.name>
+        <spotbugs-maven-plugin.version>4.1.3</spotbugs-maven-plugin.version>
         <spring-boot-maven-plugin.version>2.3.3.RELEASE</spring-boot-maven-plugin.version>
+        <spotbugs.slf4j.version>1.8.0-beta4</spotbugs.slf4j.version>
+        <spotbugs.bug-pattern.version>1.5.0</spotbugs.bug-pattern.version>
+        <spotbugs.version>4.2.0</spotbugs.version>
         <swagger-codegen-maven-plugin.version>3.0.18</swagger-codegen-maven-plugin.version>
         <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
         <tag.version>${project.version}</tag.version>
+
+        <jacoco.reportDirectory.aggregate>${project.reporting.outputDirectory}/jacoco-aggregate</jacoco.reportDirectory.aggregate>
+        <sonar.coverage.jacoco.xmlReportPaths>
+            ../cps-ri/target/site/jacoco-ut/jacoco.xml,
+            ../cps-ri/target/site/jacoco-aggregate/jacoco.xml,
+            ../cps-service/target/site/jacoco-ut/jacoco.xml,
+            ../cps-service/target/site/jacoco-aggregate/jacoco.xml,
+            ../cps-rest/target/site/jacoco-ut/jacoco.xml,
+            ../cps-rest/target/site/jacoco-aggregate/jacoco.xml,
+        </sonar.coverage.jacoco.xmlReportPaths>
     </properties>
 
     <distributionManagement>
                 </pluginManagement>
             </build>
         </profile>
-        <profile>
-            <id>skip-db-tests</id>
-            <activation>
-                <!-- exclude module tests by default till Jenkins is configured to support test containers -->
-                <activeByDefault>true</activeByDefault>
-            </activation>
-            <build>
-                <plugins>
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-surefire-plugin</artifactId>
-                        <configuration>
-                            <excludes>
-                                <exclude>**/spi/impl/*Test.java</exclude>
-                            </excludes>
-                        </configuration>
-                    </plugin>
-                </plugins>
-            </build>
-        </profile>
     </profiles>
 
     <dependencyManagement>
                         </to>
                     </configuration>
                 </plugin>
+                <plugin>
+                    <groupId>com.github.spotbugs</groupId>
+                    <artifactId>spotbugs-maven-plugin</artifactId>
+                    <version>${spotbugs-maven-plugin.version}</version>
+                    <dependencies>
+                        <dependency>
+                            <groupId>com.github.spotbugs</groupId>
+                            <artifactId>spotbugs</artifactId>
+                            <version>${spotbugs.version}</version>
+                        </dependency>
+                        <dependency>
+                            <groupId>${project.groupId}</groupId>
+                            <artifactId>spotbugs</artifactId>
+                            <version>${project.version}</version>
+                        </dependency>
+                        <dependency>
+                            <!-- The SpotBugs Maven plugin uses SLF4J 1.8 beta 2 -->
+                            <groupId>org.slf4j</groupId>
+                            <artifactId>slf4j-simple</artifactId>
+                            <version>${spotbugs.slf4j.version}</version>
+                        </dependency>
+                    </dependencies>
+                    <configuration>
+                        <plugins>
+                            <plugin>
+                                <groupId>jp.skypencil.findbugs.slf4j</groupId>
+                                <artifactId>bug-pattern</artifactId>
+                                <version>1.5.0</version>
+                            </plugin>
+                        </plugins>
+                        <!--
+                          Enables analysis which takes more memory but finds more bugs.
+                          If you run out of memory, changes the value of the effort element
+                          to 'Low'.
+                        -->
+                        <effort>Max</effort>
+                        <!-- Reports all bugs (other values are medium and max) -->
+                        <threshold>Low</threshold>
+                        <!-- Build doesn't fail if problems are found -->
+                        <failOnError>true</failOnError>
+                        <!-- References the excluded rules -->
+                        <excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
+                        <!-- Produces XML report -->
+                        <xmlOutput>true</xmlOutput>
+                        <!-- Configures the directory in which the XML report is created -->
+                        <xmlOutputDirectory>${project.build.directory}/spotbugs</xmlOutputDirectory>
+                    </configuration>
+                    <executions>
+                        <!--
+                          Ensures that SpotBugs inspects source code when project is compiled.
+                        -->
+                        <execution>
+                            <id>analyze-compile</id>
+                            <phase>compile</phase>
+                            <goals>
+                                <goal>check</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
             </plugins>
         </pluginManagement>
         <plugins>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
+                    <!--suppress UnresolvedMavenProperty -->
                     <argLine>${surefireArgLine}</argLine>
                     <useFile>false</useFile>
                     <includes>
                     <excludes>
                         <exclude>**/IT*.java</exclude>
                     </excludes>
+                    <environmentVariables>
+                        <!--
+                            disable privileged container usage to cleanup the test containers;
+                            these will be removed automatically on jvm termination;
+                            see https://www.testcontainers.org/features/configuration/#disabling-ryuk
+                         -->
+                        <TESTCONTAINERS_RYUK_DISABLED>true</TESTCONTAINERS_RYUK_DISABLED>
+                    </environmentVariables>
                 </configuration>
             </plugin>
             <plugin>
                             <goal>check</goal>
                         </goals>
                         <configuration>
+                            <excludes>
+                                <exclude>org/onap/cps/rest/model/*</exclude>
+                            </excludes>
                             <dataFile>${project.build.directory}/code-coverage/jacoco-ut.exec</dataFile>
                             <rules>
                                 <rule>
                             </rules>
                         </configuration>
                     </execution>
+                    <execution>
+                        <id>report</id>
+                        <goals>
+                            <goal>report-aggregate</goal>
+                        </goals>
+                        <phase>verify</phase>
+                        <configuration>
+                            <dataFileIncludes>
+                                <fileInclude>**/code-coverage/jacoco-ut.exec</fileInclude>
+                            </dataFileIncludes>
+                        </configuration>
+                    </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>com.github.spotbugs</groupId>
+                <artifactId>spotbugs-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.sonarsource.scanner.maven</groupId>
+                <artifactId>sonar-maven-plugin</artifactId>
+            </plugin>
         </plugins>
     </build>
 </project>
\ No newline at end of file