<?xml version="1.0"?>
<!--
  ~ Copyright (C) 2018-2025 Niels Basjes
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~ https://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<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>nl.basjes.collections</groupId>
  <artifactId>prefixmap-parent</artifactId>
  <version>2.1.0</version>

  <packaging>pom</packaging>

  <name>PrefixMap :</name>
  <description>A datastructure the allows looking up the best matching prefix.</description>

  <properties>
    <target.java.version>1.8</target.java.version>
    <target.java.release>8</target.java.release>

    <!--  We test with Kryo 4.x to ensure backwards compatibility. -->
    <kryo4.version>4.0.3</kryo4.version>
    <kryo5.version>5.6.2</kryo5.version>

    <!-- In order for everything to work correctly we need at least this version of maven. -->
    <maven.minimal.version>3.5.2</maven.minimal.version>

    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.build.outputEncoding>UTF-8</project.build.outputEncoding>

    <!-- Needed to make the build reproducible https://reproducible-builds.org/ -->
    <project.build.outputTimestamp>2025-04-28T13:28:29Z</project.build.outputTimestamp>

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

    <checkstyle-plugin.version>3.6.0</checkstyle-plugin.version>
    <checkstyle.version>10.23.1</checkstyle.version>
    <slf4j.version>2.0.17</slf4j.version>
    <rat.version>0.16.1</rat.version>
    <jacoco.version>0.8.13</jacoco.version>

    <!-- See http://www.eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html-->
    <jacoco.surefireArgLine />
    <argLine>@{jacoco.surefireArgLine} -Xmx2048m</argLine>

    <junit5.version>5.12.2</junit5.version>
    <hamcrest-core.version>2.2</hamcrest-core.version>

    <sonar.language>java</sonar.language>
    <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
    <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
    <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>

    <git-commit-id-plugin.version>9.0.1</git-commit-id-plugin.version>
    <version.copyright>Copyright (C) 2018-2025 Niels Basjes</version.copyright>
    <version.license>License Apache 2.0</version.license>
    <version.url>${project.url}</version.url>
  </properties>

  <url>https://github.com/nielsbasjes/prefixmap</url>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>${junit5.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-reload4j</artifactId>
      <version>${slf4j.version}</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <profiles>

    <profile>
      <id>skipQuality</id>
      <properties>
        <skipTests>true</skipTests>
        <sonar.skip>true</sonar.skip>
        <rat.skip>true</rat.skip>
        <checkstyle.skip>true</checkstyle.skip>
        <jacoco.skip>true</jacoco.skip>
        <spotbugs.skip>true</spotbugs.skip>
        <dependency-convergence.phase>none</dependency-convergence.phase>
        <invoker.skip>true</invoker.skip>
        <cyclonedx.skip>true</cyclonedx.skip>
        <gpg.skip>true</gpg.skip>
      </properties>
    </profile>

    <profile>
      <id>artifactCompare</id>
      <build>
        <defaultGoal>clean verify</defaultGoal>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-artifact-plugin</artifactId>
            <executions>
              <execution>
                <id>compare</id>
                <goals>
                  <goal>compare</goal>
                </goals>
                <phase>verify</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>packageForRelease</id>
      <properties>
        <maven.build.cache.enabled>false</maven.build.cache.enabled>
      </properties>
      <build>
        <plugins>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-artifact-plugin</artifactId>
            <executions>
              <execution>
                <id>Ensure plugins are reproducible</id>
                <phase>validate</phase>
                <goals>
                  <goal>check-buildplan</goal>
                </goals>
              </execution>
              <execution>
                <id>Generate buildinfo</id>
                <goals>
                  <goal>buildinfo</goal>
                </goals>
                <configuration>
                  <attach>true</attach>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>3.2.7</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>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.11.2</version>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <!-- https://central.sonatype.org/publish/publish-portal-maven/ -->
          <plugin>
            <groupId>org.sonatype.central</groupId>
            <artifactId>central-publishing-maven-plugin</artifactId>
            <version>0.7.0</version>
            <extensions>true</extensions>
            <configuration>
              <publishingServerId>central</publishingServerId>
              <!--              <autoPublish>true</autoPublish>-->
              <!--              <waitUntil>published</waitUntil>-->
              <waitUntil>validated</waitUntil>
              <excludeArtifacts>
                <excludeArtifact>prefixmap-devtools</excludeArtifact>
                <excludeArtifact>prefixmap-serialization-tests-parent</excludeArtifact>
                <excludeArtifact>prefixmap-serialization-tests</excludeArtifact>
                <excludeArtifact>prefixmap-serialization-tests-base</excludeArtifact>
                <excludeArtifact>prefixmap-serialization-tests-java</excludeArtifact>
                <excludeArtifact>prefixmap-serialization-tests-java-kryo-4</excludeArtifact>
                <excludeArtifact>prefixmap-serialization-tests-java-kryo-5</excludeArtifact>
              </excludeArtifacts>
            </configuration>
          </plugin>

        </plugins>
      </build>
    </profile>

    <profile>
      <id>EnableReportPlugins</id>
      <build>
        <plugins>

          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.eluder.coveralls</groupId>
            <artifactId>coveralls-maven-plugin</artifactId>
            <version>4.3.0</version>
            <configuration>
              <timestampFormat>EpochMillis</timestampFormat>
            </configuration>
            <dependencies>
              <dependency>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>2.3.1</version>
              </dependency>
            </dependencies>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>SkipSonarIfNotConfigured</id>
      <activation>
        <property>
          <name>!env.SONAR_TOKEN</name>
        </property>
      </activation>
      <properties>
        <sonar.skip>true</sonar.skip>
      </properties>
    </profile>

  </profiles>

  <build>
    <defaultGoal>clean package</defaultGoal>

    <pluginManagement>
      <plugins>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-clean-plugin</artifactId>     <version>3.4.1</version>  </plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-install-plugin</artifactId>   <version>3.1.4</version>  </plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId>       <version>3.4.2</version>  </plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-resources-plugin</artifactId> <version>3.3.1</version>  </plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-site-plugin</artifactId>      <version>3.21.0</version> </plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId>  <version>3.14.0</version> </plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-enforcer-plugin</artifactId>  <version>3.5.0</version>  </plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-source-plugin</artifactId>    <version>3.3.1</version>  </plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-javadoc-plugin</artifactId>   <version>3.11.2</version> </plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-gpg-plugin</artifactId>       <version>3.2.7</version>  </plugin>

        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.5.3</version>
          <configuration>
            <failIfNoTests>true</failIfNoTests>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-artifact-plugin</artifactId>
          <version>3.6.0</version>
          <configuration>
            <skipModules>
              <skipModule>nl.basjes.collections/prefixmap-devtools</skipModule>
              <skipModule>nl.basjes.collections/prefixmap-serialization-tests-parent</skipModule>
              <skipModule>nl.basjes.collections/prefixmap-serialization-tests</skipModule>
              <skipModule>nl.basjes.collections/prefixmap-serialization-tests-base</skipModule>
              <skipModule>nl.basjes.collections/prefixmap-serialization-tests-java</skipModule>
              <skipModule>nl.basjes.collections/prefixmap-serialization-tests-java-kryo-4</skipModule>
              <skipModule>nl.basjes.collections/prefixmap-serialization-tests-java-kryo-5</skipModule>
            </skipModules>
          </configuration>
        </plugin>

        <plugin>
          <groupId>io.github.git-commit-id</groupId>
          <artifactId>git-commit-id-maven-plugin</artifactId>
          <version>${git-commit-id-plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>${checkstyle-plugin.version}</version>
          <dependencies>
            <dependency>
              <groupId>nl.basjes.collections</groupId>
              <artifactId>prefixmap-devtools</artifactId>
              <version>${project.version}</version>
            </dependency>
            <dependency>
              <groupId>com.puppycrawl.tools</groupId>
              <artifactId>checkstyle</artifactId>
              <version>${checkstyle.version}</version>
            </dependency>
          </dependencies>
          <configuration>
            <consoleOutput>true</consoleOutput>
            <configLocation>checkstyle/checkstyle.xml</configLocation>
            <suppressionsLocation>checkstyle/suppressions.xml</suppressionsLocation>
            <includeTestSourceDirectory>true</includeTestSourceDirectory>
          </configuration>
          <!-- Runs by default in the verify phase  (mvn verify or later in the build cycle)
               the 'check' goal will fail the build if it does not pass.  "mvn checkstyle:check"
               will do this alone, or "mvn checkstyle:checkstyle" will report but not break  -->
          <executions>
            <execution>
              <id>checkstyle-check</id>
              <phase>validate</phase>
              <goals>
                <goal>check</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- Coverage analysis for tests -->
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>${jacoco.version}</version>
          <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>
                <!--
                    Sets the name of the property containing the settings
                    for JaCoCo runtime agent.
                -->
                <propertyName>jacoco.surefireArgLine</propertyName>
              </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>
            </execution>
          </executions>
        </plugin>

      </plugins>
    </pluginManagement>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <!-- Based upon https://maven.apache.org/plugins/maven-compiler-plugin/examples/module-info.html-->
        <executions>
          <execution>
            <id>Compile for Java 9 to build correct module-info</id>
            <configuration>
              <!-- compile everything to ensure module-info contains right entries -->
              <release>9</release>
            </configuration>
          </execution>
          <execution>
            <id>Compile for Java 8 to build classes correctly</id>
            <goals>
              <goal>compile</goal>
            </goals>
            <!-- recompile everything for target VM except the module-info.java -->
            <configuration>
              <excludes>
                <exclude>module-info.java</exclude>
              </excludes>
              <release>${target.java.release}</release>
              <compilerArgument>
                -Xlint:unchecked
              </compilerArgument>
              <showWarnings>true</showWarnings>
              <showDeprecation>true</showDeprecation>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <!-- This here is to lie to plugins like javadoc -->
          <release>9</release>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

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

      <plugin>
        <!-- Description: https://github.com/git-commit-id/git-commit-id-maven-plugin -->
        <groupId>io.github.git-commit-id</groupId>
        <artifactId>git-commit-id-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>Populate maven properties for git information</id>
            <phase>validate</phase>
            <goals>
              <goal>revision</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <dateFormat>yyyy-MM-dd '@' HH:mm:ss z</dateFormat>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <executions>
          <execution>
            <id>Enforce build environment</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireMavenVersion>
                  <version>[${maven.minimal.version},)</version>
                  <message>You must use Maven version ${maven.minimal.version} or newer to build this project.</message>
                  <!-- Reasons for this need:                            -->
                  <!-- https://issues.apache.org/jira/browse/MDEPLOY-221 -->
                  <!-- https://issues.apache.org/jira/browse/MNG-6581    -->
                </requireMavenVersion>
                <requireJavaVersion>
                  <message>You need JDK 11 or newer to build this project. The end result will be a Java 9 module that can still be used as a normal Java 8 dependency</message>
                  <version>[11,)</version>
                </requireJavaVersion>
                <dependencyConvergence />
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.rat</groupId>
        <artifactId>apache-rat-plugin</artifactId>
        <version>${rat.version}</version>
        <inherited>false</inherited>
        <!-- https://issues.apache.org/jira/browse/RAT-158 -->
        <dependencies>
          <dependency>
            <groupId>org.apache.maven.doxia</groupId>
            <artifactId>doxia-core</artifactId>
            <version>2.0.0</version>
            <exclusions>
              <exclusion>
                <groupId>xerces</groupId>
                <artifactId>xercesImpl</artifactId>
              </exclusion>
            </exclusions>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>Enforce licence header compliance</id>
            <phase>validate</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <consoleOutput>true</consoleOutput>
          <excludeSubProjects>false</excludeSubProjects>
          <excludes>
            <!-- Version control files -->
            <exclude>**/.git/**</exclude>
            <exclude>**/.gitignore</exclude>
            <!-- IDE settings and files -->
            <exclude>**/.classpath</exclude>
            <exclude>**/.project</exclude>
            <exclude>**/.settings/**</exclude>
            <exclude>**/.idea/**</exclude>
            <exclude>**/*.iml</exclude>
            <exclude>*.patch</exclude>
            <exclude>*.diff</exclude>
            <!-- Files that cannot be 'polluted' -->
            <exclude>.github/**</exclude>
            <exclude>**/*.json</exclude>
            <exclude>**/*.ndjson</exclude>
            <exclude>CNAME</exclude>
            <exclude>CODEOWNERS</exclude>
            <!-- File generated during build -->
            <exclude>**/target/**</exclude>
            <exclude>**/dependency-reduced-pom.xml</exclude>
            <!-- Other files -->
            <exclude>ReleaseProcedure.txt</exclude>
            <exclude>**/.~lock.*</exclude>
            <exclude>**/*.md</exclude>
            <exclude>.git-hooks/commit-msg.d/sailr.sh</exclude>
            <!-- Test scripts -->
            <exclude>*.sh</exclude>
            <exclude>**/_*/**</exclude>
          </excludes>
        </configuration>
      </plugin>

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

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>3.1.1</version>
        <dependencies>
          <dependency>
            <groupId>nl.basjes.maven.release</groupId>
            <artifactId>conventional-commits-version-policy</artifactId>
            <version>1.0.7</version>
          </dependency>
        </dependencies>
        <configuration>
          <autoVersionSubmodules>true</autoVersionSubmodules>

          <scmCommentPrefix>Release:</scmCommentPrefix>
          <scmReleaseCommitComment>Release: Version @{releaseLabel}</scmReleaseCommitComment>
          <scmDevelopmentCommitComment>Release: Start development of next version</scmDevelopmentCommitComment>
          <scmRollbackCommitComment>Release: Rollback the release of @{releaseLabel}</scmRollbackCommitComment>

          <tagNameFormat>v@{project.version}</tagNameFormat>
          <projectVersionPolicyId>ConventionalCommitsVersionPolicy</projectVersionPolicyId>
          <projectVersionPolicyConfig>
            <versionTag>^v([0-9]+\.[0-9]+\.[0-9]+)$</versionTag>
          </projectVersionPolicyConfig>

          <preparationProfiles>packageForRelease</preparationProfiles>
          <preparationGoals>clean verify</preparationGoals>
          <releaseProfiles>packageForRelease</releaseProfiles>
          <pushChanges>false</pushChanges>
          <remoteTagging>false</remoteTagging>
        </configuration>
      </plugin>

    </plugins>
  </build>

  <modules>
    <module>devtools</module>
    <module>prefixmap</module>
    <module>serialization</module>
  </modules>

  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>Niels Basjes</name>
      <email>niels@basjes.nl</email>
      <roles>
        <role>Architect</role>
        <role>Developer</role>
      </roles>
      <timezone>Europe/Amsterdam</timezone>
    </developer>
  </developers>

  <scm>
    <url>https://github.com/nielsbasjes/prefixmap</url>
    <connection>scm:git:https://github.com/nielsbasjes/prefixmap.git</connection>
    <developerConnection>scm:git:file:///${project.basedir}</developerConnection>
    <tag>v2.1.0</tag>
  </scm>

</project>
