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

<!--
  ~ =============================================================================
  ~
  ~   Copyright (c) 2019-2025 Arxila OSS (https://arxila.io)
  ~
  ~   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
  ~
  ~       http://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 https://maven.apache.org/maven-v4_0_0.xsd"
         child.project.url.inherit.append.path="false">

  <modelVersion>4.0.0</modelVersion>

  <groupId>io.arxila</groupId>
  <artifactId>arxila-parent</artifactId>
  <packaging>pom</packaging>
  <version>1.0.2</version>
  <name>Arxila OSS Java parent POM</name>
  <description>Parent POM for Arxila Open Source Java projects</description>
  <url>https://arxila.io</url>

  <organization>
    <name>Arxila OSS</name>
    <url>https://arxila.io</url>
  </organization>

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

  <developers>
    <developer>
      <name>Arxila</name>
      <organization>Arxila OSS</organization>
      <organizationUrl>https://arxila.io</organizationUrl>
    </developer>
  </developers>

  <scm child.scm.url.inherit.append.path="false"
       child.scm.developerConnection.inherit.append.path="false">
    <url>https://github.com/arxila/${project.artifactId}</url>
    <developerConnection>scm:git:git@github.com:arxila/${project.artifactId}</developerConnection>
  </scm>

  <distributionManagement>
    <snapshotRepository>
      <id>central-portal-snapshots</id>
      <name>Central Portal Snapshots</name>
      <url>https://central.sonatype.com/repository/maven-snapshots/</url>
    </snapshotRepository>
  </distributionManagement>

  <repositories>
    <repository>
      <id>central-portal-snapshots</id>
      <name>Central Portal Snapshots</name>
      <url>https://central.sonatype.com/repository/maven-snapshots/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <properties>
    <java.version>17</java.version>
    <javadoc.version>${java.version}</javadoc.version>
    <maven.compiler.source>${java.version}</maven.compiler.source>
    <maven.compiler.target>${java.version}</maven.compiler.target>
    <maven.compiler.release>${java.version}</maven.compiler.release>
    <project.build.sourceEncoding>US-ASCII</project.build.sourceEncoding>
    <project.build.propertiesEncoding>ISO-8859-1</project.build.propertiesEncoding>
    <resource.delimiter>@</resource.delimiter>
    <!-- These are needed for showing the build timestamp correctly at                -->
    <!-- the ${project.artifactId}.properties file inside lib jars.                   -->
    <timestamp>${maven.build.timestamp}</timestamp>
    <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ssZ</maven.build.timestamp.format>
    <!-- ======================     -->
    <!-- OPERATIONAL flags          -->
    <!-- ======================     -->
    <!-- Only the 'releases' profile will enable deployment of artifacts.   -->
    <artifact.deploy.disabled>true</artifact.deploy.disabled>
    <!-- ======================     -->
    <!-- MODULE configuration       -->
    <!-- ======================     -->
    <module.name>arxila.${project.artifactId}</module.name>
    <!-- =========================  -->
    <!-- Configure JavaDoc plugin   -->
    <!-- =========================  -->
    <maven.javadoc.source>${javadoc.version}</maven.javadoc.source>
    <maven.javadoc.release>${javadoc.version}</maven.javadoc.release>
    <!-- ======================     -->
    <!-- DEPENDENCY versions        -->
    <!-- ======================     -->
    <commons-lang3.version>3.17.0</commons-lang3.version>
    <junit.version>5.11.3</junit.version>
    <!-- ======================     -->
    <!-- MAVEN PLUGIN versions      -->
    <!-- ======================     -->
    <maven-clean-plugin.version>3.4.0</maven-clean-plugin.version>
    <maven-dependency-plugin.version>3.8.1</maven-dependency-plugin.version>
    <maven-compiler-plugin.version>3.13.0</maven-compiler-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-jar-plugin.version>3.4.2</maven-jar-plugin.version>
    <maven-javadoc-plugin.version>3.11.1</maven-javadoc-plugin.version>
    <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
    <maven-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>
    <maven-deploy-plugin.version>3.1.3</maven-deploy-plugin.version>
    <maven-scm-plugin.version>2.1.0</maven-scm-plugin.version>
    <maven-antrun-plugin.version>3.1.0</maven-antrun-plugin.version>
    <maven-assembly-plugin.version>3.7.1</maven-assembly-plugin.version>
    <maven-versions-plugin.version>2.18.0</maven-versions-plugin.version>
    <maven-central-publishing-plugin.version>0.7.0</maven-central-publishing-plugin.version>
  </properties>

  <dependencyManagement>
    <dependencies>

      <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>${commons-lang3.version}</version>
      </dependency>

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

    </dependencies>
  </dependencyManagement>

  <build>

    <pluginManagement>
      <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-dependency-plugin</artifactId>
          <version>${maven-dependency-plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${maven-compiler-plugin.version}</version>
          <configuration>
            <!-- This will generate metadata for reflection on method parameters (JDK8+)        -->
            <parameters>true</parameters>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>${maven-resources-plugin.version}</version>
          <configuration>
            <encoding>${project.build.sourceEncoding}</encoding>
            <propertiesEncoding>${project.build.propertiesEncoding}</propertiesEncoding>
            <delimiters>
              <!-- We set the resource delimiters to only @*@ in order to avoid the ${*} syntax -->
              <!-- colliding with properties meant to be resolved by Spring.                    -->
              <delimiter>${resource.delimiter}</delimiter>
            </delimiters>
            <useDefaultDelimiters>false</useDefaultDelimiters>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${maven-surefire-plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>${maven-failsafe-plugin.version}</version>
          <executions>
            <execution>
              <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <classesDirectory>${project.build.outputDirectory}</classesDirectory>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${maven-jar-plugin.version}</version>
          <configuration>
            <archive>
              <addMavenDescriptor>false</addMavenDescriptor>
              <manifest>
                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
              </manifest>
              <manifestEntries>
                <!-- These two entries are non-standard, specified by the Apache Software       -->
                <!-- Foundation in their release preparation procedures as a way to pass this   -->
                <!-- information on to the project users. See:                                  -->
                <!-- http://commons.apache.org/releases/prepare.html                            -->
                <X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
                <X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK>
                <!-- Set the Built-By attribute to avoid displaying specific usernames.         -->
                <Built-By>arxila</Built-By>
                <!-- Setting this automatic module name will fix the module name being used     -->
                <!-- even if the project is not yet fully modularised.                          -->
                <Automatic-Module-Name>${module.name}</Automatic-Module-Name>
              </manifestEntries>
            </archive>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>${maven-javadoc-plugin.version}</version>
          <configuration>
            <show>protected</show>
            <noqualifier>java.lang</noqualifier>
            <source>${maven.javadoc.source}</source>
            <release>${maven.javadoc.release}</release>
            <overview>${basedir}/src/main/javadoc/overview.html</overview>
            <javadocDirectory>${basedir}/src/main/javadoc</javadocDirectory>
            <outputDirectory>${project.build.directory}</outputDirectory>
            <doclint>all,-missing</doclint>
          </configuration>
          <executions>
            <execution>
              <id>javadoc-jar</id>
              <phase>package</phase>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>${maven-source-plugin.version}</version>
          <executions>
            <execution>
              <id>source-jar</id>
              <phase>package</phase>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>${maven-gpg-plugin.version}</version>
          <configuration>
            <skip>${artifact.deploy.disabled}</skip>
          </configuration>
          <executions>
            <execution>
              <id>gpg-sign</id>
              <phase>verify</phase>
              <goals>
                <goal>sign</goal>
              </goals>
              <configuration>
                <keyname>releases@arxila.io</keyname>
              </configuration>
            </execution>
          </executions>
        </plugin>

        <!-- IMPORTANT: maven-deploy-plugin is skipped. Deployment will always  -->
        <!-- be handled by central-publishing-maven-plugin.                     -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>${maven-deploy-plugin.version}</version>
          <configuration>
            <skip>true</skip>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>${maven-antrun-plugin.version}</version>
          <executions>
            <!-- Copy javadoc's "element-list" file to "package-list" in order to allow         -->
            <!-- projects using versions of the javadoc tool < JDK9 to properly link to         -->
            <!-- the project's javadoc as an external link.                                     -->
            <!-- NOTE this modifies the javadoc AFTER the creation of the jar as it is not      -->
            <!-- possible to do so by previously configuring javadoc:javadoc in the             -->
            <!-- prepare-package phase because this "package-list" modification would trigger a -->
            <!-- second execution of the javadoc tool in the javadoc:jar goal.                  -->
            <execution>
              <id>copy-javadoc-element-list-to-package-list</id>
              <phase>package</phase>
              <goals>
                <goal>run</goal>
              </goals>
              <configuration>
                <target name="copy javadocs element-list to package-list">
                  <copy file="${project.build.directory}/apidocs/element-list"
                        tofile="${project.build.directory}/apidocs/package-list"
                        failonerror="false" />
                </target>
              </configuration>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-scm-plugin</artifactId>
          <version>${maven-scm-plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>${maven-assembly-plugin.version}</version>
          <executions>
            <execution>
              <id>make-assembly-dist</id>
              <phase>package</phase>
              <goals>
                <goal>single</goal>
              </goals>
              <configuration>
                <descriptors>
                  <descriptor>src/assembly/dist.xml</descriptor>
                </descriptors>
                <appendAssemblyId>true</appendAssemblyId>
                <finalName>${project.artifactId}-${project.version}</finalName>
              </configuration>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>versions-maven-plugin</artifactId>
          <version>${maven-versions-plugin.version}</version>
        </plugin>

        <!-- IMPORTANT: central-publishing-maven-plugin works like this:        -->
        <!--   * If there are no explicit executions configured for it, it will -->
        <!--     add an execution of its "publish" goal to the "deploy" phase,  -->
        <!--     and also search for the presence of maven-deploy-plugin and    -->
        <!--     nexus-staging-maven-plugin and REMOVE their executions, so     -->
        <!--     that only central-publishing-maven-plugin executes during      -->
        <!--     the "deploy" phase.                                            -->
        <plugin>
          <groupId>org.sonatype.central</groupId>
          <artifactId>central-publishing-maven-plugin</artifactId>
          <version>${maven-central-publishing-plugin.version}</version>
          <extensions>true</extensions>
          <configuration>
            <publishingServerId>central</publishingServerId>
            <skipPublishing>${artifact.deploy.disabled}</skipPublishing>
          </configuration>
        </plugin>

      </plugins>
    </pluginManagement>

  </build>

  <profiles>
    <profile>
      <id>releases</id>
      <properties>
        <artifact.deploy.disabled>false</artifact.deploy.disabled>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.sonatype.central</groupId>
            <artifactId>central-publishing-maven-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
