<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>tools.bestquality</groupId>
    <artifactId>ossrh-parent</artifactId>
    <version>0.0.17</version>
    <name>OSSRH Parent</name>
    <description>Maven Central Parent</description>
    <packaging>pom</packaging>

    <properties>
        <!-- Plugin Versions -->
        <codehaus.versions.version>2.7</codehaus.versions.version>
        <maven.ci.version>0.0.19</maven.ci.version>
        <maven.deploy.version>2.8.2</maven.deploy.version>
        <maven.gpg.version>1.6</maven.gpg.version>
        <maven.failsafe.version>2.22.2</maven.failsafe.version>
        <maven.jacoco.version>0.8.5</maven.jacoco.version>
        <maven.jar.version>3.2.0</maven.jar.version>
        <maven.javadoc.version>3.1.1</maven.javadoc.version>
        <maven.site.version>3.7.1</maven.site.version>
        <maven.source.version>3.2.1</maven.source.version>
        <maven.surefire.version>2.22.2</maven.surefire.version>
        <nexus.staging.version>1.6.8</nexus.staging.version>
        <!-- CI Versioning -->
        <revision>0.0.17</revision>
        <sha1/>
        <changelist/>
        <!-- Build Properties -->
        <java.version>1.8</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <skipTests>false</skipTests>
        <skipITests>${skipTests}</skipITests>
        <skipSite>true</skipSite>
        <skipSiteDeploy>${skipSite}</skipSiteDeploy>
        <!-- Customized Properties -->
        <ossrh.hostname>s01.oss.sonatype.org</ossrh.hostname>
        <ossrh.staging-profile>7e430683fef886</ossrh.staging-profile>
        <repository.slug>Best-Quality-Engineering/ossrh-parent</repository.slug>
    </properties>

    <url>https://github.com/${repository.slug}</url>

    <licenses>
        <license>
            <name>Apache 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0</url>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:git://github.com/${repository.slug}.git</connection>
        <developerConnection>scm:git:git@github.com:${repository.slug}.git</developerConnection>
        <url>https://github.com/${repository.slug}</url>
        <tag>HEAD</tag>
    </scm>

    <ciManagement>
        <system>github-actions</system>
        <url>https://github.com/${repository.slug}/actions</url>
    </ciManagement>

    <distributionManagement>
        <site>
            <id>gh-pages</id>
            <name>gh-pages</name>
            <url>scm:git:git@github.com:${repository.slug}.git</url>
        </site>
    </distributionManagement>

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

    <developers>
        <developer>
            <id>Jeff-Glatz</id>
            <name>Jeff Glatz</name>
            <email>jeff@bestquality.engineering</email>
        </developer>
    </developers>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>tools.bestquality</groupId>
                    <artifactId>ci-maven-plugin</artifactId>
                    <version>${maven.ci.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>expand-pom</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>${maven.jar.version}</version>
                    <executions>
                        <execution>
                            <configuration>
                                <skipIfEmpty>true</skipIfEmpty>
                            </configuration>
                            <goals>
                                <goal>test-jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>${maven.source.version}</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <goals>
                                <goal>jar</goal>
                                <goal>test-jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven.surefire.version}</version>
                    <configuration>
                        <argLine>${surefire.jacoco.args}</argLine>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${maven.failsafe.version}</version>
                    <configuration>
                        <skip>${skipITests}</skip>
                        <skipITs>${skipITests}</skipITs>
                        <skipTests>${skipITests}</skipTests>
                        <argLine>${failsafe.jacoco.args}</argLine>
                        <parallel>classes</parallel>
                        <threadCount>5</threadCount>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>${maven.javadoc.version}</version>
                    <configuration>
                        <doclint>none</doclint>
                    </configuration>
                    <executions>
                        <execution>
                            <id>attach-javadocs</id>
                            <goals>
                                <goal>jar</goal>
                                <goal>test-jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>${maven.site.version}</version>
                    <configuration>
                        <skip>${skipSite}</skip>
                        <skipDeploy>${skipSiteDeploy}</skipDeploy>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>versions-maven-plugin</artifactId>
                    <version>${codehaus.versions.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${maven.jacoco.version}</version>
                    <executions>
                        <execution>
                            <id>before-unit-test-execution</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                            <configuration>
                                <destFile>${project.build.directory}/jacoco/exec/unit.exec</destFile>
                                <propertyName>surefire.jacoco.args</propertyName>
                            </configuration>
                        </execution>
                        <execution>
                            <id>after-unit-test-execution</id>
                            <phase>test</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                            <configuration>
                                <dataFile>${project.build.directory}/jacoco/exec/unit.exec</dataFile>
                                <outputDirectory>${project.build.directory}/jacoco/report/unit</outputDirectory>
                            </configuration>
                        </execution>
                        <execution>
                            <id>before-integration-test-execution</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                            <configuration>
                                <destFile>${project.build.directory}/jacoco/exec/integration.exec</destFile>
                                <propertyName>failsafe.jacoco.args</propertyName>
                            </configuration>
                        </execution>
                        <execution>
                            <id>after-integration-test-execution</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                            <configuration>
                                <dataFile>${project.build.directory}/jacoco/exec/integration.exec</dataFile>
                                <outputDirectory>${project.build.directory}/jacoco/report/integration</outputDirectory>
                            </configuration>
                        </execution>
                        <execution>
                            <id>merge-unit-and-integration</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>merge</goal>
                            </goals>
                            <configuration>
                                <fileSets>
                                    <fileSet>
                                        <directory>${project.build.directory}/jacoco/exec</directory>
                                        <includes>
                                            <include>*.exec</include>
                                        </includes>
                                    </fileSet>
                                </fileSets>
                                <destFile>${project.build.directory}/jacoco.exec</destFile>
                            </configuration>
                        </execution>
                        <execution>
                            <id>create-merged-report</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                            <configuration>
                                <dataFile>${project.build.directory}/jacoco.exec</dataFile>
                                <outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>tools.bestquality</groupId>
                <artifactId>ci-maven-plugin</artifactId>
                <inherited>false</inherited>
                <configuration>
                    <documents>
                        <document>
                            <location>${project.basedir}/README.md</location>
                            <encoding>utf-8</encoding>
                            <pattern><![CDATA[(?sm)(<version>).*?(<\/version>)]]></pattern>
                            <replacement><![CDATA[$1${project.version}$2]]></replacement>
                        </document>
                        <document>
                            <location>${project.basedir}/docs/_config.yml</location>
                            <encoding>utf-8</encoding>
                            <pattern><![CDATA[(version:).*]]></pattern>
                            <replacement><![CDATA[$1 ${project.version}]]></replacement>
                        </document>
                    </documents>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
            </plugin>
            <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-surefire-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>ossrh</id>
            <distributionManagement>
                <snapshotRepository>
                    <id>ossrh</id>
                    <url>https://${ossrh.hostname}/content/repositories/snapshots</url>
                </snapshotRepository>
                <repository>
                    <id>ossrh</id>
                    <url>https://${ossrh.hostname}/service/local/staging/deploy/maven2</url>
                </repository>
            </distributionManagement>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${maven.gpg.version}</version>
                        <configuration>
                            <defaultKeyring>true</defaultKeyring>
                            <keyname>${env.CODE_SIGNING_KEY_FINGERPRINT}</keyname>
                            <passphrase>${env.CODE_SIGNING_KEY_PASSPHRASE}</passphrase>
                            <!-- GPG 2.1 requires pinentry-mode to be set to loopback in order to pick up gpg.passphrase -->
                            <gpgArguments>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-deploy-plugin</artifactId>
                        <version>${maven.deploy.version}</version>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>${nexus.staging.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://${ossrh.hostname}</nexusUrl>
                            <stagingProfileId>${ossrh.staging-profile}</stagingProfileId>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                            <autoDropAfterRelease>true</autoDropAfterRelease>
                            <detectBuildFailures>true</detectBuildFailures>
                        </configuration>
                        <executions>
                            <execution>
                                <id>default-deploy</id>
                                <phase>deploy</phase>
                                <goals>
                                    <goal>deploy</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
