<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>eu.mapow</groupId>
  <artifactId>mapow-maven-bom</artifactId>
  <name>mapow-maven-bom</name>
  <description>parent pom</description>
  <version>1.7</version>
  <packaging>pom</packaging>

  <organization />
  <url>https://github.com/katermurr/mapow-maven-bom.git</url>

  <licenses>
    <license>
      <name>MIT License</name>
      <url>https://opensource.org/license/mit</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>mapow</name>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:git://github.com/katermurr/mapow-maven-bom.git</connection>
    <developerConnection>scm:git:ssh://github.com:katermurr/mapow-maven-bom.git</developerConnection>
    <url>https://github.com/katermurr/mapow-maven-bom.git</url>
    <tag>HEAD</tag>
  </scm>

  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/releases//</url>
    </repository>
    <!--  <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository> -->
  </distributionManagement>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>21</java.version>
    <maven.version>3.9.9</maven.version>

    <!-- maven core plugin versions -->
    <maven-clean-plugin.version>3.4.0</maven-clean-plugin.version>
    <maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
    <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
    <maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
    <maven-surefire-plugin.version>3.5.2</maven-surefire-plugin.version>
    <maven-failsafe-plugin.version>3.5.2</maven-failsafe-plugin.version>
    <maven-install-plugin.version>3.1.3</maven-install-plugin.version>
    <maven-deploy-plugin.version>3.1.3</maven-deploy-plugin.version>

    <!-- nexus deploy -->
    <maven-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>
    <nexus-staging-maven-plugin.version>1.7.0</nexus-staging-maven-plugin.version>
    <checksum-maven-plugin.version>1.11</checksum-maven-plugin.version>
    <central-publishing-maven-plugin.version>0.6.0</central-publishing-maven-plugin.version>

    <!-- maven reporting plugin versions -->
    <maven-site-plugin.version>3.21.0</maven-site-plugin.version>
    <maven-project-info-reports-plugin.version>3.8.0</maven-project-info-reports-plugin.version>
    <maven-javadoc-plugin.version>3.11.1</maven-javadoc-plugin.version>
    <dependency-check-maven.version>11.1.0</dependency-check-maven.version>
    <maven-jxr-plugin.version>3.6.0</maven-jxr-plugin.version>
    <maven-versions-maven-plugin>2.18.0</maven-versions-maven-plugin>
    <taglist-maven-plugin.version>3.2.1</taglist-maven-plugin.version>
    <spotbugs.maven.plugin.version>4.8.6.6</spotbugs.maven.plugin.version>
    <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>

    <!-- additional maven plugins -->
    <build-helper-maven-plugin.version>3.6.0</build-helper-maven-plugin.version>
    <maven-release-plugin.version>3.1.1</maven-release-plugin.version>
    <maven-enforcer-plugin.version>3.5.0</maven-enforcer-plugin.version>

    <!-- initial coverage values -->
    <jacoco.instruction.coverage>100%</jacoco.instruction.coverage>
    <jacoco.class.missedcount>0</jacoco.class.missedcount>
    <jacoco.line.coverage>100%</jacoco.line.coverage>
    <jacoco.branch.coverage>100%</jacoco.branch.coverage>
    <jacoco.method.coverage>100%</jacoco.method.coverage>
  </properties>

  <build>
    <pluginManagement>
      <plugins>
        <!-- core plugins-->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>${maven-clean-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${maven-compiler-plugin.version}</version>
          <configuration>
            <release>${java.version}</release>
            <parameters>true</parameters>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>${maven-source-plugin.version}</version>
          <executions>
            <execution>
              <id>attach-sources</id>
              <phase>verify</phase>
              <goals>
                <goal>jar-no-fork</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>${maven-resources-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${maven-surefire-plugin.version}</version>
          <configuration>
            <!-- given by jacoco-maven-plugin-->
            <argLine>${surefire.jacoco.args}</argLine>
            <excludes>
              <exclude>**/*IntegrationTest*</exclude>
            </excludes>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>${maven-failsafe-plugin.version}</version>
          <configuration>
            <!-- fix: IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test-->
            <!-- https://issues.apache.org/jira/browse/SUREFIRE-1198?focusedCommentId=16674086&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16674086 -->
            <classesDirectory>${project.build.outputDirectory}</classesDirectory>
            <!-- given by jacoco-maven-plugin-->
            <argLine>${failsafe.jacoco.args}</argLine>
            <includes>
              <include>**/*IntegrationTest*</include>
            </includes>
          </configuration>
          <executions>
            <execution>
              <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-install-plugin</artifactId>
          <version>${maven-install-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>${maven-deploy-plugin.version}</version>
        </plugin>

        <!-- reporting plugins-->
        <!-- add site and info plugin within pluginManagement to prevent LinkageError 'void org.apache.maven.doxia.sink.Sink.verbatim()' with mvn clean site -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-site-plugin</artifactId>
          <version>${maven-site-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>${maven-project-info-reports-plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>${maven-javadoc-plugin.version}</version>
          <configuration>
            <failOnError>false</failOnError>
            <!-- https://www.baeldung.com/java-doclint-->
            <additionalJOption>-Xdoclint:none</additionalJOption>
            <!-- https://stackoverflow.com/questions/39979045/no-public-or-protected-classes-found-to-document-error-from-path-with-accents -->
            <additionalOptions>-package</additionalOptions>
          </configuration>
          <executions>
            <execution>
              <id>attach-javadoc</id>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.owasp</groupId>
          <artifactId>dependency-check-maven</artifactId>
          <version>${dependency-check-maven.version}</version>
          <configuration>
            <ossindexAnalyzerEnabled>false</ossindexAnalyzerEnabled>
            <retireJsAnalyzerEnabled>false</retireJsAnalyzerEnabled>
            <nuspecAnalyzerEnabled>false</nuspecAnalyzerEnabled>
            <assemblyAnalyzerEnabled>false</assemblyAnalyzerEnabled>
            <!-- https://nvd.nist.gov/developers/request-an-api-key -->
            <nvdApiKey>ed0a3c54-afbd-4949-84ce-680dbb9d5dff</nvdApiKey>
          </configuration>
          <executions>
            <execution>
              <goals>
                <goal>check</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>com.github.spotbugs</groupId>
          <artifactId>spotbugs-maven-plugin</artifactId>
          <version>${spotbugs.maven.plugin.version}</version>
          <executions>
            <execution>
              <phase>verify</phase>
              <goals>
                <goal>spotbugs</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <xmlOutput>true</xmlOutput>
            <htmlOutput>true</htmlOutput>
            <outputDirectory>${project.build.directory}/spotbugs</outputDirectory>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>${jacoco-maven-plugin.version}</version>
          <executions>
            <!-- unit tests coverage data -->
            <execution>
              <id>before-unit-test-execution</id>
              <goals>
                <goal>prepare-agent</goal>
              </goals>
              <configuration>
                <destFile>${project.build.directory}/jacoco.exec</destFile>
                <propertyName>surefire.jacoco.args</propertyName>
              </configuration>
            </execution>
            <!-- unit tests report -->
            <execution>
              <id>after-unit-test-execution</id>
              <phase>test</phase>
              <goals>
                <goal>report</goal>
              </goals>
              <configuration>
                <dataFile>${project.build.directory}/jacoco.exec</dataFile>
                <outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
              </configuration>
            </execution>
            <!-- integration tests coverage data -->
            <execution>
              <id>before-integration-test-execution</id>
              <phase>pre-integration-test</phase>
              <goals>
                <goal>prepare-agent</goal>
              </goals>
              <configuration>
                <destFile>${project.build.directory}/jacoco-it.exec</destFile>
                <propertyName>failsafe.jacoco.args</propertyName>
              </configuration>
            </execution>
            <!-- integration tests report -->
            <execution>
              <id>after-integration-test-execution</id>
              <phase>post-integration-test</phase>
              <goals>
                <goal>report</goal>
              </goals>
              <configuration>
                <dataFile>${project.build.directory}/jacoco-it.exec</dataFile>
                <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
              </configuration>
            </execution>
            <!-- aggregated coverage data -->
            <execution>
              <id>merge-unit-and-integration</id>
              <phase>post-integration-test</phase>
              <goals>
                <goal>merge</goal>
              </goals>
              <configuration>
                <!-- required to prevent "The parameters 'fileSets' for goal merge are missing or invalid" -->
                <fileSets>
                  <fileSet>
                    <directory>${project.build.directory}</directory>
                    <includes>
                      <include>*.exec</include>
                    </includes>
                  </fileSet>
                </fileSets>
                <!-- change default jacoco.exec which is used for unit tests ! -->
                <destFile>${project.build.directory}/jacoco-merged.exec</destFile>
              </configuration>
            </execution>
            <!-- aggregated coverage report -->
            <execution>
              <id>create-merged-report</id>
              <phase>post-integration-test</phase>
              <goals>
                <goal>report</goal>
              </goals>
              <configuration>
                <dataFile>${project.build.directory}/jacoco-merged.exec</dataFile>
                <outputDirectory>${project.reporting.outputDirectory}/jacoco-aggregate</outputDirectory>
              </configuration>
            </execution>
            <!-- check coverage ratio -->
            <execution>
              <id>check</id>
              <phase>verify</phase>
              <goals>
                <goal>check</goal>
              </goals>
              <configuration>
                <rules>
                  <rule>
                    <element>BUNDLE</element>
                    <limits>
                      <limit>
                        <counter>INSTRUCTION</counter>
                        <value>COVEREDRATIO</value>
                        <minimum>${jacoco.instruction.coverage}</minimum>
                      </limit>
                      <limit>
                        <counter>CLASS</counter>
                        <value>MISSEDCOUNT</value>
                        <maximum>${jacoco.class.missedcount}</maximum>
                      </limit>
                    </limits>
                  </rule>
                  <rule>
                    <element>CLASS</element>
                    <limits>
                      <limit>
                        <counter>LINE</counter>
                        <value>COVEREDRATIO</value>
                        <minimum>${jacoco.line.coverage}</minimum>
                      </limit>
                      <limit>
                        <counter>BRANCH</counter>
                        <value>COVEREDRATIO</value>
                        <minimum>${jacoco.branch.coverage}</minimum>
                      </limit>
                      <limit>
                        <counter>METHOD</counter>
                        <value>COVEREDRATIO</value>
                        <minimum>${jacoco.method.coverage}</minimum>
                      </limit>
                    </limits>
                  </rule>
                </rules>
                <dataFile>${project.build.directory}/jacoco-merged.exec</dataFile>
              </configuration>
            </execution>
          </executions>
        </plugin>

        <!-- additional maven plugins -->
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>${build-helper-maven-plugin.version}</version>
          <executions>
            <execution>
              <id>add-integration-test-sources</id>
              <phase>generate-test-sources</phase>
              <goals>
                <goal>add-test-source</goal>
              </goals>
              <configuration>
                <sources>
                  <source>src/integration-test/java</source>
                </sources>
              </configuration>
            </execution>
            <execution>
              <id>add-integration-test-resources</id>
              <phase>generate-resources</phase>
              <goals>
                <goal>add-test-resource</goal>
              </goals>
              <configuration>
                <resources>
                  <resource>
                    <directory>src/integration-test/resources</directory>
                  </resource>
                </resources>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <version>${maven-release-plugin.version}</version>
          <configuration>
            <tagNameFormat>RELEASE-${project.artifactId}-v@{project.version}</tagNameFormat>
            <autoVersionSubmodules>true</autoVersionSubmodules>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>${maven-enforcer-plugin.version}</version>
          <executions>
            <execution>
              <id>enforce-versions</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <rules>
                  <bannedPlugins>
                    <!-- will only display a warning but does not fail the build. -->
                    <level>WARN</level>
                    <excludes>
                      <exclude>
                        org.apache.maven.plugins:maven-verifier-plugin</exclude>
                    </excludes>
                    <message>
                      Please consider using the maven-invoker-plugin
                      (http://maven.apache.org/plugins/maven-invoker-plugin/)!</message>
                  </bannedPlugins>
                  <bannedDependencies>
                    <searchTransitive>true</searchTransitive>
                    <excludes>
                      <exclude>commons-logging:commons-logging</exclude>
                      <exclude>log4j:log4j</exclude>
                      <exclude>org.apache.httpcomponents:httpclient:(4.3]</exclude>
                    </excludes>
                    <message>A banned dependency or plugin was found!</message>
                  </bannedDependencies>
                  <requireMavenVersion>
                    <version>${maven.version}</version>
                  </requireMavenVersion>
                  <requireJavaVersion>
                    <version>${java.version}</version>
                  </requireJavaVersion>
                  <dependencyConvergence>
                    <level>WARN</level>
                  </dependencyConvergence>
                  <banDuplicatePomDependencyVersions />
                </rules>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
      </plugin>
      <!-- required for jacoco integration tests report -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

  <!-- mvn clean verify site site:stage -->
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jxr-plugin</artifactId>
        <version>${maven-jxr-plugin.version}</version>
        <reportSets>
          <reportSet>
            <id>aggregate</id>
            <inherited>false</inherited>
            <reports>
              <report>aggregate</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>versions-maven-plugin</artifactId>
        <version>${maven-versions-maven-plugin}</version>
        <reportSets>
          <reportSet>
            <reports>
              <report>dependency-updates-report</report>
              <report>dependency-updates-aggregate-report</report>
              <report>plugin-updates-report</report>
              <report>plugin-updates-aggregate-report</report>
              <report>property-updates-report</report>
              <report>property-updates-aggregate-report</report>
              <report>parent-updates-report</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>taglist-maven-plugin</artifactId>
        <version>${taglist-maven-plugin.version}</version>
        <configuration>
          <tagListOptions>
            <tagClasses>
              <tagClass>
                <displayName>Todo Work</displayName>
                <tags>
                  <tag>
                    <matchString>todo</matchString>
                    <matchType>ignoreCase</matchType>
                  </tag>
                  <tag>
                    <matchString>FIXME</matchString>
                    <matchType>exact</matchType>
                  </tag>
                </tags>
              </tagClass>
            </tagClasses>
          </tagListOptions>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.owasp</groupId>
        <artifactId>dependency-check-maven</artifactId>
        <reportSets>
          <reportSet>
            <reports>
              <report>aggregate</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
      <plugin>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-maven-plugin</artifactId>
      </plugin>
      <!-- Code Coverage report in mvn site -->
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
          <!-- required otherwise the aggregated report from mvn verify is overriden empty -->
          <includeCurrentProject>true</includeCurrentProject>
        </configuration>
        <reportSets>
          <reportSet>
            <reports>
              <report>report</report>
              <report>report-integration</report>
              <report>report-aggregate</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>

  <profiles>
    <profile>
      <id>nexus</id>
      <activation>
        <property>
          <name>release</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>${maven-gpg-plugin.version}</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
                <configuration>
                  <gpgArguments>
                    <arg>--pinentry-mode</arg>
                    <arg>loopback</arg>
                  </gpgArguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>net.nicoulaj.maven.plugins</groupId>
            <artifactId>checksum-maven-plugin</artifactId>
            <version>${checksum-maven-plugin.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>artifacts</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <!-- TODO: account is not registered for ossrh -->
          <!-- https://central.sonatype.org/register/legacy/ -->
          <!-- <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>${nexus-staging-maven-plugin.version}</version>
            <extensions>true</extensions>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
              <autoReleaseAfterClose>true</autoReleaseAfterClose>
            </configuration>
          </plugin> -->
         <!-- no snapshots so far: https://central.sonatype.org/faq/registered-on-portal-oss-errors/#answer -->
         <plugin>
            <groupId>org.sonatype.central</groupId>
            <artifactId>central-publishing-maven-plugin</artifactId>
            <version>${central-publishing-maven-plugin.version}</version>
            <extensions>true</extensions>
            <configuration>
              <publishingServerId>ossrh</publishingServerId>
              <autoPublish>true</autoPublish>
              <waitForPublishCompletion>false</waitForPublishCompletion>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
