<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>io.phasetwo</groupId>
  <artifactId>oss-parent</artifactId>
  <packaging>pom</packaging>
  <version>0.13</version>

  <name>${project.groupId}:${project.artifactId}</name>
  <description>Parent pom for oss projects</description>
  <url>https://github.com/xgp/oss-parent</url>

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

  <developers>
    <developer>
      <name>Phase Two, Inc.</name>
      <url>https://github.com/p2-inc</url>
    </developer>
  </developers>

  <scm>
    <url>https://github.com/p2-inc/oss-parent</url>
    <connection>scm:git:git@github.com:p2-inc/oss-parent.git</connection>
    <tag>v0.13</tag>
  </scm>

  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <name>Sonatype OSS Snapshots Repository</name>
      <url>${ossrh.url}/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <name>Sonatype OSS Release Staging Repository</name>
      <url>${ossrh.url}/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.test.skip>false</maven.test.skip>
    <maven.integration.skip>true</maven.integration.skip>
    <release.sign.skip>false</release.sign.skip>
    <java.version>1.8</java.version>
    <ossrh.url>https://ossrh-staging-api.central.sonatype.com</ossrh.url>
  </properties>

  <build>
    <defaultGoal>install</defaultGoal>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>3.3.1</version>
        <configuration>
          <scmCommentPrefix>[ci skip]</scmCommentPrefix>
          <tagNameFormat>v@{project.version}</tagNameFormat>
          <autoVersionSubmodules>true</autoVersionSubmodules>
          <releaseProfiles>releases</releaseProfiles>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.diffplug.spotless</groupId>
          <artifactId>spotless-maven-plugin</artifactId>
          <version>3.6.0</version>
          <configuration>
            <ratchetFrom>origin/main</ratchetFrom>
            <java>
              <removeUnusedImports />
              <forbidWildcardImports />
              <googleJavaFormat>
                <style>GOOGLE</style>
                <formatJavadoc>false</formatJavadoc>
              </googleJavaFormat>
            </java>
            <pom>
              <includes>
                <include>pom.xml</include>
              </includes>
              <!-- <sortPom /> --> <!-- Let me enable this in a later PR as this will 'cause a huge change in all pom.xmls; let rollout gradual the java validation for now -->
            </pom>
          </configuration>
          <executions>
            <execution>
              <goals>
                <goal>check</goal>
              </goals>
              <phase>compile</phase>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.15.0</version>
          <configuration>
            <debug>true</debug>
            <source>${java.version}</source>
            <target>${java.version}</target>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>buildnumber-maven-plugin</artifactId>
          <version>3.3.0</version>
          <executions>
            <execution>
              <id>detect-scm-revision</id>
              <phase>validate</phase>
              <goals>
                <goal>create</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <getRevisionOnlyOnce>true</getRevisionOnlyOnce>
            <shortRevisionLength>8</shortRevisionLength>
            <doCheck>false</doCheck>
            <doUpdate>false</doUpdate>
            <timestampFormat>{0,date,yyyyMMdd}</timestampFormat>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.4.0</version>
          <executions>
            <execution>
              <id>attach-sources</id>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>3.1.4</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.5.0</version>
          <executions>
            <execution>
              <id>default-jar</id>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <archive>
              <manifestEntries>
                <Built-By />
                <Specification-Title>${project.name}</Specification-Title>
                <Specification-Version>${project.version}</Specification-Version>
                <Specification-Vendor>${project.organization.name}</Specification-Vendor>
                <Implementation-Title>${project.name}</Implementation-Title>
                <Implementation-Version>${project.version}</Implementation-Version>
                <Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
                <Implementation-Build>${implementation.build}</Implementation-Build>
              </manifestEntries>
            </archive>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>
    <profile>
      <id>doclint-java8-disable</id>
      <activation>
        <jdk>[1.8,)</jdk>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.12.0</version>
            <configuration>
              <source>8</source>
              <additionalparam>-Xdoclint:none</additionalparam>
              <detectJavaApiLink>false</detectJavaApiLink>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>releases</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.4.0</version>
            <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-javadoc-plugin</artifactId>
            <version>3.12.0</version>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>3.2.8</version>
            <configuration>
              <gpgArguments>
                <arg>--pinentry-mode</arg>
                <arg>loopback</arg>
              </gpgArguments>
            </configuration>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
                <configuration>
                  <skip>${release.sign.skip}</skip>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <extensions>true</extensions>
            <version>1.7.0</version>
            <executions>
              <execution>
                <id>default-deploy</id>
                <phase>deploy</phase>
                <goals>
                  <goal>deploy</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>${ossrh.url}/</nexusUrl>
              <autoReleaseAfterClose>true</autoReleaseAfterClose>
              <!-- <autoDropAfterRelease>true</autoDropAfterRelease> -->
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
