<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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.computablefacts</groupId>
    <artifactId>logfmt</artifactId>
    <version>0.1</version>
    <packaging>jar</packaging>

    <name>logfmt</name>
    <description>Java package for generating and parsing log lines in the logfmt style.</description>
    <url>https://github.com/computablefacts/logfmt</url>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
            <comments>A business-friendly OSS license</comments>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:git@github.com:computablefacts/logfmt.git</connection>
        <developerConnection>scm:git:git@github.com:computablefacts/logfmt.git</developerConnection>
        <url>https://github.com/computablefacts/logfmt.git</url>
        <tag>HEAD</tag>
    </scm>

    <developers>
        <developer>
            <name>ComputableFacts</name>
            <email>engineering@computablefacts.com</email>
            <url>https://computablefacts.com</url>
        </developer>
    </developers>

    <properties>
        <guava.version>28.0-jre</guava.version>
        <error-prone.version>2.3.1</error-prone.version>
        <jackson.version>2.9.8</jackson.version>
        <slf4j.version>1.7.21</slf4j.version>
        <log4j.version>1.2.17</log4j.version>
        <junit.version>4.12</junit.version>
        <maven-shade-plugin.version>3.1.1</maven-shade-plugin.version>
        <maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
        <maven-source-plugin.version>2.2.1</maven-source-plugin.version>
        <maven-javadoc-plugin.version>2.9.1</maven-javadoc-plugin.version>
        <maven-nexus-staging-plugin.version>1.6.8</maven-nexus-staging-plugin.version>
        <maven-jacoco-plugin.version>0.8.5</maven-jacoco-plugin.version>
        <maven-surefire-plugin.version>3.0.0-M3</maven-surefire-plugin.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${guava.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.errorprone</groupId>
            <artifactId>error_prone_annotations</artifactId>
            <version>${error-prone.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>${basedir}/src</sourceDirectory>
        <testSourceDirectory>${basedir}/test</testSourceDirectory>
        <resources>
            <resource>
                <directory>${basedir}/src/resources</directory>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>${basedir}/test/resources</directory>
            </testResource>
        </testResources>
        <plugins>

            <!-- Restrict Imports -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.0.0-M2</version>
                <dependencies>
                    <dependency>
                        <groupId>de.skuzzle.enforcer</groupId>
                        <artifactId>restrict-imports-enforcer-rule</artifactId>
                        <version>1.1.0</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>check-logging-imports</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <restrictImports
                                        implementation="de.skuzzle.enforcer.restrictimports.rule.RestrictImports">
                                    <reason>Logfmt must not inherit from Nona</reason>
                                    <bannedImport>com.computablefacts.nona.**</bannedImport>
                                </restrictImports>
                                <restrictImports
                                        implementation="de.skuzzle.enforcer.restrictimports.rule.RestrictImports">
                                    <reason>Logfmt must not inherit from Decima</reason>
                                    <bannedImport>com.computablefacts.decima.**</bannedImport>
                                </restrictImports>
                                <restrictImports
                                        implementation="de.skuzzle.enforcer.restrictimports.rule.RestrictImports">
                                    <reason>Logfmt must not inherit from Morta</reason>
                                    <bannedImport>com.computablefacts.morta.**</bannedImport>
                                </restrictImports>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Compile project using Google Error-Prone -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <compilerId>javac-with-errorprone</compilerId>
                    <showWarnings>true</showWarnings>
                    <compilerArgs>
                        <arg>-Xep:ClassName</arg>
                        <arg>-Xep:DepAnn</arg>
                        <arg>-Xep:EmptyIf</arg>
                        <arg>-Xep:NoAllocation</arg>
                        <arg>-Xep:NumericEquality</arg>
                        <arg>-Xep:NonCanonicalStaticMemberImport</arg>
                        <arg>-Xep:PrimitiveArrayPassedToVarargsMethod</arg>
                        <arg>-Xep:StringEquality</arg>
                        <arg>-Xep:Var:ERROR</arg>
                        <arg>-Xep:WildcardImport</arg>
                        <arg>-XepDisableWarningsInGeneratedCode</arg>
                        <arg>-XepExcludedPaths:.*/org/tartarus/snowball/.*|.*/RDRPOSTagger/jSCRDRtagger/.*</arg>
                    </compilerArgs>
                    <forceJavacCompilerUse>true</forceJavacCompilerUse>
                    <!-- maven-compiler-plugin defaults to targeting Java 5, but our javac only supports >=6 -->
                    <source>8</source>
                    <target>8</target>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.plexus</groupId>
                        <artifactId>plexus-compiler-javac-errorprone</artifactId>
                        <version>2.8.3</version>
                    </dependency>
                    <!-- override plexus-compiler-javac-errorprone's dependency on Error Prone with the latest version -->
                    <dependency>
                        <groupId>com.google.errorprone</groupId>
                        <artifactId>error_prone_core</artifactId>
                        <version>${error-prone.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

            <!-- Enable git commit id -->
            <plugin>
                <groupId>pl.project13.maven</groupId>
                <version>${git-commit-id-plugin.version}</version>
                <artifactId>git-commit-id-plugin</artifactId>
                <executions>
                    <execution>
                        <id>get-the-git-infos</id>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>validate-the-git-infos</id>
                        <goals>
                            <goal>validateRevision</goal>
                        </goals>
                        <phase>package</phase>
                    </execution>
                </executions>
                <configuration>
                    <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
                    <prefix>git</prefix>
                    <verbose>false</verbose>
                    <generateGitPropertiesFile>true</generateGitPropertiesFile>
                    <generateGitPropertiesFilename>
                        ${project.build.outputDirectory}/git-logfmt.properties
                    </generateGitPropertiesFilename>
                    <format>json</format>
                    <gitDescribe>
                        <skip>false</skip>
                        <always>false</always>
                        <dirty>-dirty</dirty>
                    </gitDescribe>
                    <!--
                    <validationProperties>
                        <validationProperty>
                            <name>validating git dirty</name>
                            <value>${git.dirty}</value>
                            <shouldMatchTo>false</shouldMatchTo>
                        </validationProperty>
                    </validationProperties>
                    -->
                </configuration>
            </plugin>

            <!-- Code Coverage Reports -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${maven-jacoco-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Unit Tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
                <configuration>
                    <parallel>methods</parallel>
                    <threadCount>5</threadCount>
                    <skipTests>false</skipTests>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>publish</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>${maven-source-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${maven-javadoc-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </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>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.8</version> <!-- ${maven-nexus-staging-plugin.version} -->
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <distributionManagement>
                <snapshotRepository>
                    <id>ossrh</id>
                    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
                </snapshotRepository>
                <repository>
                    <id>ossrh</id>
                    <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
                </repository>
            </distributionManagement>
        </profile>
    </profiles>
</project>