From 6558f9603de1380c748fc7b36e80547a8df24578 Mon Sep 17 00:00:00 2001
From: Julien CORNILLE <julien.cornille@xelians.fr>
Date: Wed, 7 Oct 2020 16:28:50 +0200
Subject: [PATCH] [TS FOX-329] Update pom.xml

- Use spotbugs instead of findbugs
- Upgrade plugin for java 11
- Add sonar-metrics profile
---
 pom.xml | 154 +++++++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 114 insertions(+), 40 deletions(-)

diff --git a/pom.xml b/pom.xml
index 38697600..002cbdfc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -144,20 +144,21 @@
         <maven.dependencycheck.version>5.2.2</maven.dependencycheck.version>
         <maven.deploy.plugin.version>2.8.2</maven.deploy.plugin.version>
         <maven.exec.plugin.version>1.6.0</maven.exec.plugin.version>
+        <maven.directory.plugin.version>0.1</maven.directory.plugin.version>
         <maven.failsafe.plugin.version>2.21.0</maven.failsafe.plugin.version>
         <maven.filtering.plugin.version>1.3</maven.filtering.plugin.version>
-        <maven.findbugs.plugin.version>3.0.4</maven.findbugs.plugin.version>
+        <maven.spotbugs.plugin.version>4.0.4</maven.spotbugs.plugin.version>
         <maven.frontend.plugin.version>1.6</maven.frontend.plugin.version>
-        <maven.jacoco.plugin.version>0.8.0</maven.jacoco.plugin.version>
+        <maven.jacoco.plugin.version>0.8.6</maven.jacoco.plugin.version>
         <maven.jar.plugin.version>3.0.2</maven.jar.plugin.version>
         <maven.javadoc.plugin.version>3.0.0</maven.javadoc.plugin.version>
         <maven.jaxb2.plugin.version>2.5.0</maven.jaxb2.plugin.version>
         <maven.lombok.plugin.version>1.18.0.0</maven.lombok.plugin.version>
-        <maven.pmd.plugin.version>3.10.0</maven.pmd.plugin.version>
+        <maven.pmd.plugin.version>3.13.0</maven.pmd.plugin.version>
         <maven.project.info.reports.plugin.version>3.0.0</maven.project.info.reports.plugin.version>
         <maven.release.plugin.version>2.5.3</maven.release.plugin.version>
         <maven.resources.plugin.version>2.7</maven.resources.plugin.version>
-        <maven.site.plugin.version>3.7.1</maven.site.plugin.version>
+        <maven.site.plugin.version>3.9.1</maven.site.plugin.version>
         <maven.sonar.plugin.version>3.4.0.905</maven.sonar.plugin.version>
         <maven.source.plugin.version>3.0.1</maven.source.plugin.version>
         <maven.surefire.plugin.version>2.22.2</maven.surefire.plugin.version>
@@ -1047,6 +1048,24 @@
                     </dependency>
                 </dependencies>
             </plugin>
+            <!-- Directory plugin to find parent root directory absolute path -->
+            <plugin>
+                <groupId>org.commonjava.maven.plugins</groupId>
+                <artifactId>directory-maven-plugin</artifactId>
+                <version>${maven.directory.plugin.version}</version>
+                <executions>
+                    <execution>
+                        <id>directories</id>
+                        <goals>
+                            <goal>highest-basedir</goal>
+                        </goals>
+                        <phase>initialize</phase>
+                        <configuration>
+                            <property>main.basedir</property>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
         <pluginManagement>
             <plugins>
@@ -1080,8 +1099,8 @@
                 <!-- find bugs in current project -->
                 <plugin>
                     <groupId>org.codehaus.mojo</groupId>
-                    <artifactId>findbugs-maven-plugin</artifactId>
-                    <version>${maven.findbugs.plugin.version}</version>
+                    <artifactId>spotbugs-maven-plugin</artifactId>
+                    <version>${maven.spotbugs.plugin.version}</version>
                 </plugin>
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
@@ -1089,7 +1108,7 @@
                     <version>${maven.pmd.plugin.version}</version>
                     <configuration>
                         <rulesets>
-                            <ruleset>${maven.multiModuleProjectDirectory}/pmd-rulesets.xml</ruleset>
+                            <ruleset>${main.basedir}/pmd-rulesets.xml</ruleset>
                         </rulesets>
                         <failOnViolation>false</failOnViolation>
                     </configuration>
@@ -1114,8 +1133,8 @@
                     <artifactId>frontend-maven-plugin</artifactId>
                     <version>${maven.frontend.plugin.version}</version>
                     <configuration>
-                        <workingDirectory>${maven.multiModuleProjectDirectory}/ui/ui-frontend</workingDirectory>
-                        <installDirectory>${maven.multiModuleProjectDirectory}/ui/ui-frontend</installDirectory>
+                        <workingDirectory>${main.basedir}/ui/ui-frontend</workingDirectory>
+                        <installDirectory>${main.basedir}/ui/ui-frontend</installDirectory>
                         <skip>${skipAllFrontend}</skip>
                     </configuration>
                     <executions>
@@ -1244,13 +1263,11 @@
                             </goals>
                         </execution>
                         <execution>
-                            <id>pre-integration-test</id>
+                            <id>jacoco-site</id>
+                            <phase>verify</phase>
                             <goals>
-                                <goal>prepare-agent-integration</goal>
+                                <goal>report</goal>
                             </goals>
-                            <configuration>
-                                <propertyName>itCoverageAgent</propertyName>
-                            </configuration>
                         </execution>
                     </executions>
                 </plugin>
@@ -1275,13 +1292,26 @@
 
     <reporting>
         <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-site-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-project-info-reports-plugin</artifactId>
+            </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-pmd-plugin</artifactId>
+                <configuration>
+                    <rulesets>
+                        <ruleset>${maven.multiModuleProjectDirectory}/pmd-rulesets.xml</ruleset>
+                    </rulesets>
+                </configuration>
             </plugin>
             <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>findbugs-maven-plugin</artifactId>
+                <groupId>com.github.spotbugs</groupId>
+                <artifactId>spotbugs-maven-plugin</artifactId>
             </plugin>
             <plugin>
                 <groupId>org.jacoco</groupId>
@@ -1403,7 +1433,7 @@
                                     <skip>${rpm.skip}</skip>
                                     <arguments>
                                         <argument>-f</argument>
-                                        <argument>${maven.multiModuleProjectDirectory}/tools/packaging/Makefile</argument>
+                                        <argument>${main.basedir}/tools/packaging/Makefile</argument>
                                         <argument>rpm</argument>
                                         <argument>NAME=${project.artifactId}</argument>
                                         <argument>VERSION=${project.version}</argument>
@@ -1438,7 +1468,7 @@
                                 </goals>
                                 <configuration>
                                     <skip>${rpm.skip}</skip>
-                                    <executable>${maven.multiModuleProjectDirectory}/tools/packaging/publish.sh</executable>
+                                    <executable>${main.basedir}/tools/packaging/publish.sh</executable>
                                     <workingDirectory>target</workingDirectory>
                                     <arguments>
                                         <argument>https://repo.teamdlab.com/upload/${rpm.publication.env}/Packages</argument>
@@ -1477,9 +1507,9 @@
             </properties>
         </profile>
 
-        <!-- This profile is used to update sonar informations.-->
+        <!-- This profile is used to generate sonar-metrics sonar informations.-->
         <profile>
-            <id>sonar</id>
+            <id>sonar-metrics</id>
             <build>
                 <resources>
                     <resource>
@@ -1497,48 +1527,88 @@
                     </plugin>
                     <plugin>
                         <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-site-plugin</artifactId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <argLine>@{argLine}</argLine>
+                        </configuration>
                     </plugin>
                     <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-project-info-reports-plugin</artifactId>
+                        <groupId>com.github.spotbugs</groupId>
+                        <artifactId>spotbugs-maven-plugin</artifactId>
+                        <configuration>
+                            <failOnError>false</failOnError>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>check</id>
+                                <phase>test</phase>
+                                <goals>
+                                    <goal>check</goal>
+                                </goals>
+                            </execution>
+                        </executions>
                     </plugin>
                     <plugin>
                         <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-surefire-plugin</artifactId>
-                    </plugin>
-                    <plugin>
-                        <groupId>org.codehaus.mojo</groupId>
-                        <artifactId>findbugs-maven-plugin</artifactId>
+                        <artifactId>maven-pmd-plugin</artifactId>
+                        <configuration>
+                            <rulesets>
+                                <ruleset>${main.basedir}/pmd-rulesets.xml</ruleset>
+                            </rulesets>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>check</id>
+                                <phase>test</phase>
+                                <goals>
+                                    <goal>check</goal>
+                                </goals>
+                            </execution>
+                        </executions>
                     </plugin>
                     <plugin>
                         <groupId>org.jacoco</groupId>
                         <artifactId>jacoco-maven-plugin</artifactId>
                     </plugin>
-                    <plugin>
-                        <groupId>org.sonarsource.scanner.maven</groupId>
-                        <artifactId>sonar-maven-plugin</artifactId>
-                    </plugin>
                 </plugins>
             </build>
             <properties>
                 <angular.build.profile></angular.build.profile>
                 <angular.test.profile>:sonar</angular.test.profile>
                 <!-- Set project configuration file for test coverage -->
-                <angular.additional.test.informations>--karma-config=${maven.multiModuleProjectDirectory}/ui/ui-frontend/projects/${angular.build.project}/karma.conf.ci.js</angular.additional.test.informations>
+                <angular.additional.test.informations>
+                    --karma-config=${main.basedir}/ui/ui-frontend/projects/${angular.build.project}/karma.conf.ci.js
+                </angular.additional.test.informations>
                 <maven.test.failure.ignore>true</maven.test.failure.ignore>
+            </properties>
+        </profile>
+        <!-- This profile is used to update sonar informations.-->
+        <profile>
+            <id>sonar</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.sonarsource.scanner.maven</groupId>
+                        <artifactId>sonar-maven-plugin</artifactId>
+                    </plugin>
+                </plugins>
+            </build>
+            <properties>
                 <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
                 <sonar.coverage.exclusions>**/*Dto.java, **/domain/*.java, **/vitam/seda/*.java, **/*spec.ts, **/*.scss, **/*.css</sonar.coverage.exclusions>
                 <sonar.cpd.exclusions>**/*Dto.java, **/domain/*.java, **/*spec.ts</sonar.cpd.exclusions>
                 <sonar.exclusions>**/node_modules/**, **/sass/**</sonar.exclusions>
+                <sonar.java.spotbugs.reportPaths>./target/spotbugsXml.xml</sonar.java.spotbugs.reportPaths>
+                <sonar.java.pmd.reportPaths>./target/pmd.xml</sonar.java.pmd.reportPaths>
                 <!-- TODO: This properties need to bo specify by the user who execute
                 the report (ex: Jenkins or developper) -->
-                <sonar.host.url />
+                <sonar.host.url/>
                 <!-- TODO: This properties need to bo specify by the user who execute
                 the report (ex: Jenkins or developper) -->
-                <sonar.login />
-                <sonar.typescript.lcov.reportPaths>${maven.multiModuleProjectDirectory}/ui/ui-frontend/target/coverage/archive/lcov.info,${maven.multiModuleProjectDirectory}/ui/ui-frontend/target/coverage/commons/lcov.info,${maven.multiModuleProjectDirectory}/ui/ui-frontend/target/coverage/flow/lcov.info,${maven.multiModuleProjectDirectory}/ui/ui-frontend/target/coverage/identity/lcov.info,${maven.multiModuleProjectDirectory}/ui/ui-frontend/target/coverage/portal/lcov.info</sonar.typescript.lcov.reportPaths>
+                <sonar.login/>
+                <sonar.typescript.lcov.reportPaths>${main.basedir}/ui/ui-frontend/target/coverage/commons/lcov.info,${main.basedir}/ui/ui-frontend/target/coverage/flow/lcov.info,${main.basedir}/ui/ui-frontend/target/coverage/identity/lcov.info,${main.basedir}/ui/ui-frontend/target/coverage/portal/lcov.info</sonar.typescript.lcov.reportPaths>
             </properties>
+
         </profile>
 
         <!-- This profile is used to generate swagger documentation. -->
@@ -1580,7 +1650,7 @@
                             </dependency>
                         </dependencies>
 						<configuration>
-							<swaggerInput>${maven.multiModuleProjectDirectory}/tools/swagger/docs/${swagger.dir}/${project.artifactId}/swagger.json</swaggerInput>
+							<swaggerInput>${main.basedir}/tools/swagger/docs/${swagger.dir}/${project.artifactId}/swagger.json</swaggerInput>
 							<outputDir>${project.build.directory}/generated-sources/swagger/</outputDir>
 							<config>
 								<swagger2markup.markupLanguage>ASCIIDOC</swagger2markup.markupLanguage>
@@ -1616,10 +1686,10 @@
 							</dependency>
 						</dependencies>
 						<configuration>
-							<sourceDirectory>${maven.multiModuleProjectDirectory}/tools/swagger/config/</sourceDirectory>
+							<sourceDirectory>${main.basedir}/tools/swagger/config/</sourceDirectory>
 							<sourceDocumentName>index.adoc</sourceDocumentName>
 							<backend>html5</backend>
-							<outputDirectory>${maven.multiModuleProjectDirectory}/tools/swagger/docs/${swagger.dir}/${project.artifactId}</outputDirectory>
+							<outputDirectory>${main.basedir}/tools/swagger/docs/${swagger.dir}/${project.artifactId}</outputDirectory>
 							<attributes>
 								<toc>left</toc>
 								<toclevels>3</toclevels>
@@ -1647,7 +1717,7 @@
                                 </goals>
                                 <configuration>
                                     <backend>pdf</backend>
-                                    <outputDirectory>${maven.multiModuleProjectDirectory}/tools/swagger/docs/${swagger.dir}/${project.artifactId}</outputDirectory>
+                                    <outputDirectory>${main.basedir}/tools/swagger/docs/${swagger.dir}/${project.artifactId}</outputDirectory>
                                 </configuration>
                             </execution>
 						</executions>
@@ -1688,6 +1758,10 @@
                     <id>snapshots</id>
                     <url>${env.SERVICE_NEXUS_URL}/repository/maven-snapshots/</url>
                 </snapshotRepository>
+                <site>
+                    <id>${project.artifactId}-site</id>
+                    <url>${project.baseUri}</url>
+                 </site>
             </distributionManagement>
 
 
-- 
GitLab