<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.draftable.api.client</groupId>
    <artifactId>draftable</artifactId>
    <version>2</version>
    <packaging>pom</packaging>

    <name>Draftable</name>
    <description>Client libraries for the Draftable document comparison API</description>
    <url>https://draftable.com</url>
    <inceptionYear>2013</inceptionYear>

    <licenses>
        <license>
            <name>MIT</name>
            <url>https://github.com/draftable/compare-api-java-client/blob/stable/LICENSE</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <organization>
        <name>Draftable</name>
        <url>https://draftable.com</url>
    </organization>

    <developers>
        <developer>
            <id>draftable</id>
            <name>Draftable</name>
            <email>contact@draftable.com</email>
            <organization>Draftable</organization>
            <organizationUrl>https://draftable.com</organizationUrl>
        </developer>
    </developers>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/draftable/compare-api-java-client/issues</url>
    </issueManagement>

    <scm>
        <connection>scm:git:https://github.com/draftable/compare-api-java-client.git</connection>
        <developerConnection>scm:git:https://github.com/draftable/compare-api-java-client.git</developerConnection>
        <url>https://github.com/draftable/compare-api-java-client</url>
    </scm>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <modules>
        <module>compare-api-java-client</module>
    </modules>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- Minimum supported JDK -->
        <jdk-version-short>8</jdk-version-short>
        <jdk-version>1.${jdk-version-short}</jdk-version>

        <!-- Compiler options -->
        <maven.compiler.failonWarning>true</maven.compiler.failonWarning>
        <maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
        <maven.compiler.showWarnings>true</maven.compiler.showWarnings>

        <!-- Plugin versions -->
        <maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
        <maven-clean-plugin.version>3.2.0</maven-clean-plugin.version>
        <maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
        <maven-deploy-plugin.version>3.0.0-M2</maven-deploy-plugin.version>
        <maven-enforcer-plugin.version>3.0.0</maven-enforcer-plugin.version>
        <maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version>
        <maven-install-plugin.version>3.0.0-M1</maven-install-plugin.version>
        <maven-jar-plugin.version>3.2.2</maven-jar-plugin.version>
        <maven-javadoc-plugin.version>3.4.0</maven-javadoc-plugin.version>
        <maven-resources-plugin.version>3.2.0</maven-resources-plugin.version>
        <maven-site-plugin.version>4.0.0-M1</maven-site-plugin.version>
        <maven-source-plugin.version>3.2.1</maven-source-plugin.version>
        <maven-surefire-plugin.version>3.0.0-M7</maven-surefire-plugin.version>
        <modernizer-maven-plugin.version>2.4.0</modernizer-maven-plugin.version>
        <nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
        <spotbugs-maven-plugin.version>4.7.0.0</spotbugs-maven-plugin.version>
        <versions-maven-plugin.version>2.11.0</versions-maven-plugin.version>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <!--
                    Apache Maven Assembly Plugin
                    https://maven.apache.org/plugins/maven-assembly-plugin/
                -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>${maven-assembly-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>make-assembly</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <!--
                    Apache Maven Clean Plugin
                    https://maven.apache.org/plugins/maven-clean-plugin/
                -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>${maven-clean-plugin.version}</version>
                </plugin>

                <!--
                    Apache Maven Compiler Plugin
                    https://maven.apache.org/plugins/maven-compiler-plugin/
                -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                </plugin>

                <!--
                    Apache Maven Deploy Plugin
                    https://maven.apache.org/plugins/maven-deploy-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>

                <!--
                    Apache Maven Enforcer Plugin
                    https://maven.apache.org/plugins/maven-enforcer-plugin/
                -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>${maven-enforcer-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>enforce-maven</id>
                            <goals>
                                <goal>enforce</goal>
                            </goals>
                            <configuration>
                                <rules>
                                    <requireMavenVersion>
                                        <version>3.3.9</version>
                                    </requireMavenVersion>
                                </rules>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                <!--
                    Apache Maven GPG Plugin
                    https://maven.apache.org/plugins/maven-gpg-plugin/
                -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-gpg-plugin</artifactId>
                    <version>${maven-gpg-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>sign-artifacts</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>sign</goal>
                            </goals>
                            <configuration>
                                <keyname>Draftable &lt;developers@draftable.com&gt;</keyname>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                <!--
                    Apache Maven Install Plugin
                    https://maven.apache.org/plugins/maven-install-plugin/
                -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>${maven-install-plugin.version}</version>
                </plugin>

                <!--
                    Apache Maven JAR Plugin
                    https://maven.apache.org/plugins/maven-jar-plugin/
                -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>${maven-jar-plugin.version}</version>
                    <configuration>
                        <!--
                            Apache Maven Archiver
                            https://maven.apache.org/shared/maven-archiver/
                        -->
                        <archive>
                            <manifest>
                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                            </manifest>
                        </archive>
                    </configuration>
                </plugin>

                <!--
                    Apache Maven Javadoc Plugin
                    https://maven.apache.org/plugins/maven-javadoc-plugin/
                -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>${maven-javadoc-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>attach-javadocs</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <!--
                    Apache Maven Resources Plugin
                    https://maven.apache.org/plugins/maven-resources-plugin/
                -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>${maven-resources-plugin.version}</version>
                </plugin>

                <!--
                    Apache Maven Site Plugin
                    https://maven.apache.org/plugins/maven-site-plugin/
                -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>${maven-site-plugin.version}</version>
                </plugin>

                <!--
                    Apache Maven Source Plugin
                    https://maven.apache.org/plugins/maven-source-plugin/
                -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>${maven-source-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <goals>
                                <goal>jar-no-fork</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <!--
                    Apache Maven Surefire Plugin
                    https://maven.apache.org/plugins/maven-surefire-plugin/
                -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven-surefire-plugin.version}</version>
                </plugin>

                <!--
                    Modernizer Maven Plugin
                    https://github.com/gaul/modernizer-maven-plugin
                -->
                <plugin>
                    <groupId>org.gaul</groupId>
                    <artifactId>modernizer-maven-plugin</artifactId>
                    <version>${modernizer-maven-plugin.version}</version>
                    <configuration>
                        <javaVersion>${jdk-version}</javaVersion>
                    </configuration>
                    <executions>
                        <execution>
                            <id>modernizer</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>modernizer</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <!--
                    Configuring Your Project for Deployment
                    https://help.sonatype.com/repomanager2/staging-releases/configuring-your-project-for-deployment
                -->
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>${nexus-staging-maven-plugin.version}</version>
                    <extensions>true</extensions>
                    <configuration>
                        <serverId>ossrh</serverId>
                        <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                        <autoReleaseAfterClose>true</autoReleaseAfterClose>
                    </configuration>
                </plugin>

                <!--
                    SpotBugs Maven Plugin
                    https://spotbugs.github.io/spotbugs-maven-plugin/
                -->
                <plugin>
                    <groupId>com.github.spotbugs</groupId>
                    <artifactId>spotbugs-maven-plugin</artifactId>
                    <version>${spotbugs-maven-plugin.version}</version>
                    <configuration>
                        <effort>max</effort>
                        <excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
                    </configuration>
                    <executions>
                        <execution>
                            <id>spotbugs</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>check</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <!--
                    Versions Maven Plugin
                    https://www.mojohaus.org/versions-maven-plugin/
                -->
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>versions-maven-plugin</artifactId>
                    <version>${versions-maven-plugin.version}</version>
                    <configuration>
                        <generateBackupPoms>false</generateBackupPoms>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>jdk-8-minus</id>
            <activation>
                <jdk>(,1.8]</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <source>${jdk-version}</source>
                            <target>${jdk-version}</target>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>jdk-9-plus</id>
            <activation>
                <jdk>[1.9,)</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <release>${jdk-version-short}</release>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!--
            Ensure the example module is not published

            We could do this by enabling skipNexusStagingDeployMojo for the
            nexus-staging-maven-plugin but that has its own problems:
            - https://issues.sonatype.org/browse/NEXUS-19853
            - https://issues.sonatype.org/browse/NEXUS-19853

            Instead exclude the example module entirely when the "publish"
            system property is defined.

            Via: https://stackoverflow.com/a/54001169/8787985
        -->
        <profile>
            <id>no-publish</id>
            <activation>
                <property>
                    <name>!publish</name>
                </property>
            </activation>
            <modules>
                <module>example</module>
            </modules>
        </profile>

        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-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-source-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>