<?xml version="1.0" encoding="UTF-8"?>

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>name.didier.david</groupId>
    <artifactId>ndd-maven</artifactId>
    <version>0.5.0</version>
    <relativePath>..</relativePath>
  </parent>

  <artifactId>ndd-maven-parent</artifactId>
  <packaging>pom</packaging>

  <name>NDD Maven Parent</name>
  <description>Common Maven configuration for NDD projects</description>

  <!-- ============================================================================================ Properties ===== -->

  <properties>

    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Maven directories ~~~~~ -->

    <project.tools.dir>${project.basedir}/src/tools</project.tools.dir>

    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Maven plugins ~~~~~ -->

    <dependencyCheck.cveValidForHours>12</dependencyCheck.cveValidForHours>
    <dependencyCheck.failBuildOnCVSSLevel>7</dependencyCheck.failBuildOnCVSSLevel>

    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Maven plugins dependencies ~~~~~ -->

    <checkstyle.version>10.3.3</checkstyle.version>
    <findsecbugs.version>1.12.0</findsecbugs.version>
    <ndd-maven-quality.version>0.5.0</ndd-maven-quality.version>
    <pmd.version>6.49.0</pmd.version>
    <spotbugs.version>4.7.2</spotbugs.version>

  </properties>

  <!-- ========================================================================================== Dependencies ===== -->

  <dependencies>

    <dependency>
      <groupId>name.didier.david</groupId>
      <artifactId>ndd-maven-quality</artifactId>
      <version>${ndd-maven-quality.version}</version>
      <scope>provided</scope>
    </dependency>

  </dependencies>

  <!-- ================================================================================================= Build ===== -->

  <build>

    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Build > PluginManagement ~~~~~ -->

    <pluginManagement>
      <plugins>

        <plugin>
          <groupId>com.github.spotbugs</groupId>
          <artifactId>spotbugs-maven-plugin</artifactId>
          <version>4.7.0.0</version>
          <dependencies>
            <dependency>
              <groupId>com.github.spotbugs</groupId>
              <artifactId>spotbugs</artifactId>
              <version>${spotbugs.version}</version>
            </dependency>
          </dependencies>
          <configuration>
            <effort>Max</effort>
            <threshold>Medium</threshold>
            <xmlOutput>true</xmlOutput>
            <excludeFilterFile>src/tools/spotbugs/suppressions.xml</excludeFilterFile>
            <plugins>
              <plugin>
                <groupId>com.h3xstream.findsecbugs</groupId>
                <artifactId>findsecbugs-plugin</artifactId>
                <version>${findsecbugs.version}</version>
              </plugin>
            </plugins>
          </configuration>
        </plugin>

        <plugin>
          <groupId>io.fabric8</groupId>
          <artifactId>docker-maven-plugin</artifactId>
          <version>0.40.1</version>
        </plugin>

        <plugin>
          <groupId>net.revelc.code.formatter</groupId>
          <artifactId>formatter-maven-plugin</artifactId>
          <version>2.19.0</version>
          <dependencies>
            <dependency>
              <groupId>name.didier.david</groupId>
              <artifactId>ndd-maven-quality</artifactId>
              <version>${ndd-maven-quality.version}</version>
            </dependency>
          </dependencies>
          <configuration>
            <!-- from ndd-maven-quality -->
            <configFile>eclipse/java-code-formatter.xml</configFile>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <dependencies>
            <dependency>
              <groupId>com.puppycrawl.tools</groupId>
              <artifactId>checkstyle</artifactId>
              <version>${checkstyle.version}</version>
            </dependency>
            <dependency>
              <groupId>name.didier.david</groupId>
              <artifactId>ndd-maven-quality</artifactId>
              <version>${ndd-maven-quality.version}</version>
            </dependency>
          </dependencies>
          <configuration>
            <!-- from ndd-maven-quality -->
            <configLocation>checkstyle/checkstyle-all.xml</configLocation>
            <propertyExpansion>basedir=${project.basedir}</propertyExpansion>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-pmd-plugin</artifactId>
          <dependencies>
            <dependency>
              <groupId>net.sourceforge.pmd</groupId>
              <artifactId>pmd-core</artifactId>
              <version>${pmd.version}</version>
            </dependency>
            <dependency>
              <groupId>net.sourceforge.pmd</groupId>
              <artifactId>pmd-java</artifactId>
              <version>${pmd.version}</version>
            </dependency>
            <dependency>
              <groupId>name.didier.david</groupId>
              <artifactId>ndd-maven-quality</artifactId>
              <version>${ndd-maven-quality.version}</version>
            </dependency>
          </dependencies>
          <configuration>
            <linkXRef>true</linkXRef>
            <rulesets>
              <!-- from ndd-maven-quality -->
              <ruleset>src/tools/pmd/pmd-main.xml</ruleset>
            </rulesets>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>taglist-maven-plugin</artifactId>
          <version>3.0.0</version>
          <configuration>
            <tagListOptions>
              <tagClasses>
                <tagClass>
                  <displayName>FIXME</displayName>
                  <tags>
                    <tag>
                      <matchString>FIXME</matchString>
                      <matchType>ignoreCase</matchType>
                    </tag>
                  </tags>
                </tagClass>
                <tagClass>
                  <displayName>TODO</displayName>
                  <tags>
                    <tag>
                      <matchString>TODO</matchString>
                      <matchType>ignoreCase</matchType>
                    </tag>
                  </tags>
                </tagClass>
              </tagClasses>
            </tagListOptions>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.owasp</groupId>
          <artifactId>dependency-check-maven</artifactId>
          <version>7.2.1</version>
          <configuration>
            <name>Dependency-Check</name>
            <cveValidForHours>${dependencyCheck.cveValidForHours}</cveValidForHours>
            <failBuildOnCVSS>${dependencyCheck.failBuildOnCVSSLevel}</failBuildOnCVSS>
            <assemblyAnalyzerEnabled>false</assemblyAnalyzerEnabled>
            <nugetconfAnalyzerEnabled>false</nugetconfAnalyzerEnabled>
            <nuspecAnalyzerEnabled>false</nuspecAnalyzerEnabled>
            <outputDirectory>${project.build.directory}/site</outputDirectory>
            <suppressionFiles>
              <suppressionFile>${project.tools.dir}/dependency-check/suppressions.xml</suppressionFile>
            </suppressionFiles>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.sonarsource.scanner.maven</groupId>
          <artifactId>sonar-maven-plugin</artifactId>
          <version>3.9.1.2184</version>
        </plugin>

      </plugins>
    </pluginManagement>

    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Build > Plugins ~~~~~ -->

    <plugins>

      <plugin>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-maven-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>net.revelc.code.formatter</groupId>
        <artifactId>formatter-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>format</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-pmd-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.owasp</groupId>
        <artifactId>dependency-check-maven</artifactId>
        <executions>
          <execution>
            <phase>test</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

    </plugins>

  </build>

  <!-- ============================================================================================= Reporting ===== -->

  <reporting>
    <plugins>

      <plugin>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-maven-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <reportSets>
          <reportSet>
            <reports>
              <report>checkstyle</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jxr-plugin</artifactId>
        <reportSets>
          <reportSet>
            <reports>
              <report>jxr</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-pmd-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>taglist-maven-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.owasp</groupId>
        <artifactId>dependency-check-maven</artifactId>
        <reportSets>
          <reportSet>
            <reports>
              <report>aggregate</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>

    </plugins>
  </reporting>

  <!-- ============================================================================================== Profiles ===== -->

  <profiles>

    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ndd.build-fast ~~~~~
    This profile MUST NOT BE ACTIVATED on CI.
    This profile MUST NOT BE ACTIVATED on the last build you do before pushing (right!?).
    Use '-Dndd.build=fast' to activate all 'ndd.build-fast' profiles, not their IDs.
    This profile skips lengthy build actions that are getting in the way:
    - Vulnerabilities check (dependency-check-maven)
    -->
    <profile>
      <id>ndd.build-fast</id>
      <activation>
        <property>
          <name>ndd.build</name>
          <value>fast</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.owasp</groupId>
            <artifactId>dependency-check-maven</artifactId>
            <configuration>
              <skip>true</skip>
            </configuration>
          </plugin>
        </plugins>
      </build>
      <reporting>
        <plugins>
          <plugin>
            <groupId>org.owasp</groupId>
            <artifactId>dependency-check-maven</artifactId>
            <configuration>
              <skip>true</skip>
            </configuration>
          </plugin>
        </plugins>
      </reporting>
    </profile>

  </profiles>

</project>
