<?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>

    <name>Shared POM for Morimekta Utilities</name>
    <description>
      Singular parent pom file for the utility projects.
    </description>
    <groupId>net.morimekta.utils</groupId>
    <artifactId>pom</artifactId>
    <version>4.2.4</version>
    <packaging>pom</packaging>
    <url>https://gitlab.com/morimekta/utils-pom</url>

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

    <distributionManagement>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
        </repository>
        <site>
            <id>morimekta</id>
            <name>morimekta.net/utils</name>
            <url>https://morimekta.net/utils</url>
        </site>
    </distributionManagement>

    <scm>
        <url>https://gitlab.com/morimekta/utils-pom.git</url>
        <developerConnection>scm:git:ssh://git@gitlab.com/morimekta/utils-pom.git</developerConnection>
        <tag>v4.2.4</tag>
    </scm>

    <developers>
        <developer>
            <id>morimekta</id>
            <name>Stein Eldar Johnsen</name>
            <email>oss@morimekta.net</email>
            <timezone>Europe/Oslo</timezone>
            <roles>
                <role>Maintainer</role>
                <role>Developer</role>
            </roles>
        </developer>
    </developers>

    <!-- 1.7 required for diff compatibility. -->
    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>

        <gpg.executable>gpg2</gpg.executable>

        <!-- project config -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.javadoc.encoding>UTF-8</project.javadoc.encoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
        <maven.javadocs.encoding>UTF-8</maven.javadocs.encoding>
        <maven.resources.encoding>UTF-8</maven.resources.encoding>
        <maven.site.encoding>UTF-8</maven.site.encoding>
        <maven.require.version>3.3.9</maven.require.version>

        <!-- Arg lines not specified, set by jacoco plugin -->
        <!-- surefireArgLine -->
        <!-- failsafeArgLine -->
        <!-- library versions -->
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin><artifactId>maven-assembly-plugin</artifactId><version>3.3.0</version></plugin>
                <plugin><artifactId>maven-clean-plugin</artifactId><version>3.1.0</version></plugin>
                <plugin><artifactId>maven-compiler-plugin</artifactId><version>3.8.1</version></plugin>
                <plugin><artifactId>maven-deploy-plugin</artifactId><version>3.0.0-M1</version></plugin>
                <plugin><artifactId>maven-enforcer-plugin</artifactId><version>3.0.0-M3</version></plugin>
                <plugin><artifactId>maven-failsafe-plugin</artifactId><version>3.0.0-M5</version></plugin>
                <plugin><artifactId>maven-gpg-plugin</artifactId><version>1.6</version></plugin>
                <plugin><artifactId>maven-install-plugin</artifactId><version>3.0.0-M1</version></plugin>
                <plugin><artifactId>maven-jar-plugin</artifactId><version>3.2.0</version></plugin>
                <plugin><artifactId>maven-javadoc-plugin</artifactId><version>3.2.0</version></plugin>
                <plugin><artifactId>maven-release-plugin</artifactId><version>3.0.0-M1</version></plugin>
                <plugin><artifactId>maven-resources-plugin</artifactId><version>3.2.0</version></plugin>
                <plugin><artifactId>maven-site-plugin</artifactId><version>3.9.1</version></plugin>
                <plugin><artifactId>maven-source-plugin</artifactId><version>3.2.1</version></plugin>
                <plugin><artifactId>maven-surefire-plugin</artifactId><version>3.0.0-M5</version></plugin>

                <!-- additional plugins -->
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>versions-maven-plugin</artifactId>
                    <version>2.8.1</version>
                </plugin>
                <plugin>
                    <groupId>com.github.spotbugs</groupId>
                    <artifactId>spotbugs-maven-plugin</artifactId>
                    <version>4.2.0</version>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.8.6</version>
                </plugin>
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>1.6.8</version>
                </plugin>
                <plugin>
                    <groupId>com.googlecode.maven-download-plugin</groupId>
                    <artifactId>download-maven-plugin</artifactId>
                    <version>1.6.1</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>enforce-maven</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>${maven.require.version}</version>
                                </requireMavenVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <compilerArgs>
                        <arg>-XDcompilePolicy=byfile</arg>
                        <arg>-Xlint:all</arg>
                        <!--
                         Otherwise it will still complain about unchecked casts
                         even though the cast was said to explicitly ignore
                        -->
                        <arg>-Xlint:-unchecked</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <configuration>
                    <rulesUri>https://gitlab.com/morimekta/utils-pom/-/raw/master/version-rules.xml</rulesUri>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs-maven-plugin</artifactId>
                <dependencies>
                    <!-- overwrite dependency on spotbugs if you want to specify the version of spotbugs -->
                    <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-api</artifactId>
                        <version>2.0.0-alpha1</version>
                    </dependency>
                    <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-simple</artifactId>
                        <version>2.0.0-alpha1</version>
                    </dependency>
                    <dependency>
                        <groupId>com.github.spotbugs</groupId>
                        <artifactId>spotbugs</artifactId>
                        <version>4.4.1</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <failOnError>true</failOnError>
                    <excludeFilterFile>${project.basedir}/spotbugs-exclude.xml</excludeFilterFile>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <doclint>all</doclint>
                    <failOnError>true</failOnError>
                    <nodeprecatedlist>true</nodeprecatedlist>
                    <additionalOptions>
                        <additionalOption>-html5</additionalOption>
                        <additionalOption>-quiet</additionalOption>
                    </additionalOptions>
                    <notimestamp>true</notimestamp>
                    <quiet>true</quiet>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <phase>package</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <configuration>
                    <tagNameFormat>v@{project.version}</tagNameFormat>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <releaseProfiles>release-sign-artifacts</releaseProfiles>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.scm</groupId>
                        <artifactId>maven-scm-api</artifactId>
                        <version>1.12.0</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.maven.scm</groupId>
                        <artifactId>maven-scm-provider-gitexe</artifactId>
                        <version>1.12.0</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-deploy</id>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <configuration>
                    <includes>
                        <include>net/morimekta/**/*</include>
                    </includes>
                    <excludes>
                        <exclude>net/morimekta/**/test/*</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <!--
                        Prepares the property pointing to the JaCoCo runtime agent which
                        is passed as VM argument when Maven the Surefire plugin is executed.
                    -->
                    <execution>
                        <id>pre-unit-test</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <!-- Sets the path to the file which contains the execution data. -->
                            <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
                            <!--
                                Sets the name of the property containing the settings
                                for JaCoCo runtime agent.
                            -->
                            <propertyName>surefireArgLine</propertyName>
                        </configuration>
                    </execution>
                    <!--
                        Ensures that the code coverage report for unit tests is created after
                        unit tests have been run.
                    -->
                    <execution>
                        <id>post-unit-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <!-- Sets the path to the file which contains the execution data. -->
                            <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
                            <!-- Sets the output directory for the code coverage report. -->
                            <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <!-- Sets the VM argument line used when unit tests are run. -->
                    <argLine>${surefireArgLine}</argLine>
                    <systemPropertyVariables>
                        <org.slf4j.simpleLogger.defaultLogLevel>off</org.slf4j.simpleLogger.defaultLogLevel>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-site-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-site</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>default-deploy</id>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>jdk11</id>
            <activation>
                <jdk>11</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <compilerArgs combine.children="append">
                                <arg>-Xplugin:ErrorProne</arg>
                            </compilerArgs>
                            <annotationProcessorPaths>
                                <path>
                                    <groupId>com.google.errorprone</groupId>
                                    <artifactId>error_prone_core</artifactId>
                                    <version>2.3.4</version>
                                </path>
                            </annotationProcessorPaths>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>release-sign-artifacts</id>
            <activation>
                <property>
                    <name>performRelease</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>sonatype</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>false</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <executable>${gpg.executable}</executable>
                                    <useAgent>true</useAgent>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
