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

    SPDX-License-Identifier: Apache-2.0

    Copyright 2021-2023 The ModiTect authors.

    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>org.moditect</groupId>
  <artifactId>moditect-org-parent</artifactId>
  <version>1.4.0.Final</version>
  <packaging>pom</packaging>

  <name>moditect-org-parent</name>
  <description>Parent POM for all Maven based ModiTect projects</description>
  <url>https://github.com/moditect</url>
  <inceptionYear>2021</inceptionYear>

  <organization>
    <name>ModiTect</name>
    <url>https://github.com/moditect</url>
  </organization>

  <properties>
    <!-- !! children should override these properties !! -->
    <project.identifier>moditect</project.identifier>
    <project.github.repository>moditect/moditect-org-parent</project.github.repository>
    <java.version>1.8</java.version>
    <!-- override when needed -->
    <enforcer.skip>false</enforcer.skip>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <maven.version>3.8.8</maven.version>
    <nexus.url>https://oss.sonatype.org</nexus.url>
    <repository.url>git@github.com:${project.github.repository}.git</repository.url>
    <!-- value comes from property git.commit.author.time -->
    <project.build.outputTimestamp>2024-02-07T20:28:54Z</project.build.outputTimestamp>
    <version.antrun.plugin>3.1.0</version.antrun.plugin>
    <version.clean.plugin>3.3.2</version.clean.plugin>
    <version.compiler.plugin>3.12.1</version.compiler.plugin>
    <version.dependency.plugin>3.6.1</version.dependency.plugin>
    <version.deploy.plugin>3.1.1</version.deploy.plugin>
    <version.enforcer.plugin>3.4.1</version.enforcer.plugin>
    <version.enforcer.extra.rules>1.7.0</version.enforcer.extra.rules>
    <version.failsafe.plugin>3.2.5</version.failsafe.plugin>
    <version.formatter.plugin>2.23.0</version.formatter.plugin>
    <version.git.plugin>4.9.10</version.git.plugin>
    <version.gpg.plugin>3.1.0</version.gpg.plugin>
    <version.impsort.plugin>1.9.0</version.impsort.plugin>
    <version.install.plugin>3.1.1</version.install.plugin>
    <version.javadoc.plugin>3.6.3</version.javadoc.plugin>
    <version.jar.plugin>3.3.0</version.jar.plugin>
    <version.jreleaser.plugin>1.10.0</version.jreleaser.plugin>
    <version.license.plugin>4.3</version.license.plugin>
    <version.nexus.plugin>1.6.13</version.nexus.plugin>
    <version.resources.plugin>3.3.1</version.resources.plugin>
    <version.source.plugin>3.3.0</version.source.plugin>
    <version.surefire.plugin>3.2.5</version.surefire.plugin>
    <version.versions.plugin>2.16.2</version.versions.plugin>
  </properties>

  <licenses>
    <license>
      <name>Apache-2.0</name>
      <url>https://spdx.org/licenses/Apache-2.0.html</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <scm>
    <connection>scm:git:${repository.url}</connection>
    <developerConnection>scm:git:${repository.url}</developerConnection>
    <url>${repository.url}</url>
    <tag>HEAD</tag>
  </scm>

  <developers>
    <developer>
      <id>gunnarmorling</id>
      <name>Gunnar Morling</name>
      <url>https://www.morling.dev</url>
      <roles>
        <role>author</role>
      </roles>
    </developer>
    <developer>
      <id>aalmiray</id>
      <name>Andres Almiray</name>
      <url>https://andresalmiray.com</url>
    </developer>
  </developers>

  <issueManagement>
    <system>github.com</system>
    <url>https://github.com/${project.github.repository}/issues</url>
  </issueManagement>

  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>${nexus.url}/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <url>${nexus.url}/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>${version.antrun.plugin}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>${version.clean.plugin}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>${version.resources.plugin}</version>
        </plugin>
        <plugin>
          <groupId>com.mycila</groupId>
          <artifactId>license-maven-plugin</artifactId>
          <version>${version.license.plugin}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${version.compiler.plugin}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>${version.dependency.plugin}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>${version.deploy.plugin}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-install-plugin</artifactId>
          <version>${version.install.plugin}</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>versions-maven-plugin</artifactId>
          <version>${version.versions.plugin}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${version.surefire.plugin}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>${version.failsafe.plugin}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${version.jar.plugin}</version>
        </plugin>
        <plugin>
          <groupId>pl.project13.maven</groupId>
          <artifactId>git-commit-id-plugin</artifactId>
          <version>${version.git.plugin}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>${version.enforcer.plugin}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>${version.source.plugin}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>${version.javadoc.plugin}</version>
        </plugin>
        <plugin>
          <groupId>org.sonatype.plugins</groupId>
          <artifactId>nexus-staging-maven-plugin</artifactId>
          <version>${version.nexus.plugin}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>${version.gpg.plugin}</version>
        </plugin>
        <plugin>
          <groupId>net.revelc.code.formatter</groupId>
          <artifactId>formatter-maven-plugin</artifactId>
          <version>${version.formatter.plugin}</version>
        </plugin>
        <plugin>
          <groupId>net.revelc.code</groupId>
          <artifactId>impsort-maven-plugin</artifactId>
          <version>${version.impsort.plugin}</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>net.revelc.code.formatter</groupId>
        <artifactId>formatter-maven-plugin</artifactId>
        <configuration combine.children="override">
          <configFile>${maven.multiModuleProjectDirectory}/etc/eclipse-formatter-config.xml</configFile>
        </configuration>
        <executions>
          <execution>
            <id>format</id>
            <goals>
              <goal>format</goal>
            </goals>
            <phase>process-sources</phase>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>net.revelc.code</groupId>
        <artifactId>impsort-maven-plugin</artifactId>
        <configuration combine.children="override">
          <groups>java.,javax.,org.,com.</groups>
          <removeUnused>true</removeUnused>
          <staticAfter>true</staticAfter>
        </configuration>
        <executions>
          <execution>
            <id>sort-imports</id>
            <goals>
              <goal>sort</goal>
            </goals>
            <phase>process-sources</phase>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <configuration combine.children="override">
          <header>${maven.multiModuleProjectDirectory}/etc/license.txt</header>
          <strictCheck>true</strictCheck>
          <excludes>
            <exclude>README.adoc</exclude>
            <exclude>README.md</exclude>
            <exclude>LICENSE.txt</exclude>
            <exclude>mvnw</exclude>
            <exclude>mvnw.cmd</exclude>
            <exclude>.mvn/wrapper/maven-wrapper.properties</exclude>
            <exclude>.mvn/wrapper/MavenWrapperDownloader.java</exclude>
          </excludes>
          <mapping>
            <yml>SCRIPT_STYLE</yml>
            <toml>SCRIPT_STYLE</toml>
          </mapping>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifestEntries>
              <Build-Timestamp>${git.commit.author.time}</Build-Timestamp>
              <Build-Revision>${git.commit.id}</Build-Revision>
            </manifestEntries>
            <manifest>
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
            </manifest>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <groupId>pl.project13.maven</groupId>
        <artifactId>git-commit-id-plugin</artifactId>
        <executions>
          <execution>
            <id>resolve-git-properties</id>
            <goals>
              <goal>revision</goal>
            </goals>
            <phase>validate</phase>
            <configuration>
              <verbose>false</verbose>
              <failOnNoGitDirectory>false</failOnNoGitDirectory>
              <generateGitPropertiesFile>true</generateGitPropertiesFile>
              <generateGitPropertiesFilename>${project.build.directory}/git.properties
              </generateGitPropertiesFilename>
              <dateFormat>yyyy-MM-dd'T'HH:mm:ssXXX</dateFormat>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>versions-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>publication</id>
      <activation>
        <property>
          <name>release</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar</goal>
                </goals>
                <configuration>
                  <attach>true</attach>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
                <configuration>
                  <attach>true</attach>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>com.coderplus.maven.plugins</groupId>
            <artifactId>copy-rename-maven-plugin</artifactId>
            <version>1.0.1</version>
            <executions>
              <execution>
                <id>copy-license-file</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>copy</goal>
                </goals>
                <configuration>
                  <sourceFile>${session.executionRootDirectory}/LICENSE.txt</sourceFile>
                  <destinationFile>${project.build.outputDirectory}/META-INF/LICENSE-${project.identifier}</destinationFile>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>stage</id>
      <properties>
        <altDeploymentRepository>local::file:${maven.multiModuleProjectDirectory}/target/staging-deploy</altDeploymentRepository>
      </properties>
      <build>
        <defaultGoal>deploy</defaultGoal>
      </build>
    </profile>

    <profile>
      <id>jreleaser</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.jreleaser</groupId>
            <artifactId>jreleaser-maven-plugin</artifactId>
            <version>${version.jreleaser.plugin}</version>
            <inherited>false</inherited>
            <configuration>
              <jreleaser>
                <project>
                  <name>ModiTect Parent</name>
                  <!--links>
                    <homepage>https://github.com/moditect/moditect-org-parent</homepage>
                    <documentation>https://github.com/moditect/moditect-org-parent</documentation>
                  </links-->
                  <java>
                    <version>8</version>
                  </java>
                </project>
                <signing>
                  <active>ALWAYS</active>
                  <armored>true</armored>
                </signing>
                <deploy>
                  <maven>
                    <nexus2>
                      <maven-central>
                        <active>ALWAYS</active>
                        <url>https://oss.sonatype.org/service/local</url>
                        <snapshotUrl>https://oss.sonatype.org/content/repositories/snapshots/</snapshotUrl>
                        <closeRepository>true</closeRepository>
                        <releaseRepository>true</releaseRepository>
                        <stagingRepositories>target/staging-deploy</stagingRepositories>
                      </maven-central>
                    </nexus2>
                  </maven>
                </deploy>
                <release>
                  <github>
                    <changelog>
                      <formatted>ALWAYS</formatted>
                      <preset>conventional-commits</preset>
                      <contributors>
                        <format>- {{contributorName}}{{#contributorUsernameAsLink}} ({{.}}){{/contributorUsernameAsLink}}</format>
                      </contributors>
                    </changelog>
                  </github>
                </release>
              </jreleaser>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>nochecks</id>
      <properties>
        <formatter.skip>true</formatter.skip>
        <impsort.skip>true</impsort.skip>
        <license.skip>true</license.skip>
        <enforcer.skip>true</enforcer.skip>
        <skipTests>true</skipTests>
      </properties>
    </profile>

    <profile>
      <id>enforcer</id>
      <activation>
        <property>
          <name>enforcer.skip</name>
          <value>false</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <executions>
              <execution>
                <phase>validate</phase>
                <goals>
                  <goal>enforce</goal>
                </goals>
                <configuration>
                  <rules combine.children="override">
                    <requireMavenVersion>
                      <version>${maven.version}</version>
                    </requireMavenVersion>
                    <requireJavaVersion>
                      <version>${java.version}</version>
                    </requireJavaVersion>
                    <enforceBytecodeVersion>
                      <maxJdkVersion>${java.version}</maxJdkVersion>
                    </enforceBytecodeVersion>
                    <dependencyConvergence/>
                    <requireUpperBoundDeps/>
                  </rules>
                </configuration>
              </execution>
            </executions>
            <dependencies>
              <dependency>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>extra-enforcer-rules</artifactId>
                <version>${version.enforcer.extra.rules}</version>
              </dependency>
            </dependencies>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
