<?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.github.tornaia</groupId>
    <artifactId>java-offline-geoip</artifactId>
    <version>${semver}</version>
    <packaging>jar</packaging>

    <name>Java Offline GeoIP</name>
    <description>Java Offline GeoIP maps any IP address to its country code</description>
    <url>https://github.com/tornaia/java-offline-geoip</url>

    <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>

    <issueManagement>
        <url>https://github.com/tornaia/java-offline-geoip/issues</url>
        <system>GitHub Issues</system>
    </issueManagement>

    <scm>
        <url>https://github.com/tornaia/java-offline-geoip</url>
        <connection>scm:git:https://github.com/tornaia/java-offline-geoip.git</connection>
        <developerConnection>scm:git:git@github.com:tornaia/java-offline-geoip.git</developerConnection>
    </scm>

    <licenses>
        <license>
            <name>Apache License 2.0</name>
            <url>https://opensource.org/licenses/Apache-2.0</url>
            <distribution>repo</distribution>
            <comments>A business-friendly OSS license</comments>
        </license>
    </licenses>

    <developers>
        <developer>
            <id>tornaia</id>
            <name>Andras Tornai</name>
            <email>tornai.andras.ede@gmail.com</email>
            <url>https://tornaiandras.com</url>
        </developer>
    </developers>

    <properties>
        <file.encoding>UTF-8</file.encoding>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <semver>0.1-SNAPSHOT</semver>

        <java.version>1.8</java.version>

        <maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
        <download-maven-plugin.version>1.4.1</download-maven-plugin.version>
        <maven-antrun-plugin.version>1.8</maven-antrun-plugin.version>
        <exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
        <jacoco-maven-plugin.version>0.8.1</jacoco-maven-plugin.version>
        <maven-surefire-plugin.version>2.22.0</maven-surefire-plugin.version>
        <maven-jar-plugin.version>3.1.0</maven-jar-plugin.version>
        <maven-source-plugin.version>3.0.1</maven-source-plugin.version>
        <maven-javadoc-plugin.version>3.0.1</maven-javadoc-plugin.version>
        <maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
        <nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
        <maven-scm-plugin.version>1.10.0</maven-scm-plugin.version>

        <junit.version>4.12</junit.version>
        <java-hamcrest.version>2.0.0.0</java-hamcrest.version>

        <sonar.java.source>1.8</sonar.java.source>
        <sonar.java.codeCoveragePlugin>jacoco</sonar.java.codeCoveragePlugin>
        <sonar.jacoco.reportPaths>${user.dir}/jacoco.exec</sonar.jacoco.reportPaths>
    </properties>

    <build>
        <resources>
            <!--  This is the default setting from the super-pom  -->
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <!--  ensure the LICENSE.txt appears in jars  -->
            <resource>
                <directory>${project.basedir}</directory>
                <targetPath>META-INF</targetPath>
                <includes>
                    <include>LICENSE.txt</include>
                </includes>
            </resource>
        </resources>
        <!--  ensure test jars also get NOTICE & LICENSE files  -->
        <testResources>
            <!--  This is the default setting from the super-pom  -->
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
            <!--  ensure the LICENSE.txt appears in jars  -->
            <testResource>
                <directory>${project.basedir}</directory>
                <targetPath>META-INF</targetPath>
                <includes>
                    <include>LICENSE.txt</include>
                </includes>
            </testResource>
        </testResources>

        <plugins>
            <plugin>
                <groupId>com.googlecode.maven-download-plugin</groupId>
                <artifactId>download-maven-plugin</artifactId>
                <version>${download-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>Download GeoLite2-Country-CSV.zip</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>wget</goal>
                        </goals>
                        <configuration>
                            <url>http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-CSV.zip</url>
                            <outputFileName>GeoLite2-Country-CSV.zip</outputFileName>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>${maven-antrun-plugin.version}</version>
                <executions>
                    <execution>
                        <id>Unzip GeoLite2-Country-CSV.zip</id>
                        <phase>process-resources</phase>
                        <configuration>
                            <target>
                                <unzip src="${project.build.directory}/GeoLite2-Country-CSV.zip" dest="${project.basedir}/src/main/resources">
                                    <patternset>
                                        <include name="**/GeoLite2-Country-Blocks-IPv4.csv"/>
                                        <include name="**/GeoLite2-Country-Blocks-IPv6.csv"/>
                                        <include name="**/GeoLite2-Country-Locations-en.csv"/>
                                    </patternset>
                                    <mapper type="flatten"/>
                                </unzip>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <compilerArgs>
                        <arg>-Xlint:all,-options,-path</arg>
                    </compilerArgs>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco-maven-plugin.version}</version>
                <configuration>
                    <includes>
                        <include>com.github.tornaia.*</include>
                    </includes>
                    <append>true</append>
                    <destFile>${sonar.jacoco.reportPaths}</destFile>
                </configuration>
                <executions>
                    <execution>
                        <id>pre-unit-test</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>post-unit-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${maven-jar-plugin.version}</version>
            </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</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${maven-javadoc-plugin.version}</version>
                <configuration>
                    <additionalOptions>
                        <additionalOption>-html5</additionalOption>
                    </additionalOptions>
                </configuration>
                <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>${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>${nexus-staging-maven-plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://oss.sonatype.org</nexusUrl>
                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-scm-plugin</artifactId>
                <version>${maven-scm-plugin.version}</version>
                <configuration>
                    <tag>${project.artifactId}-${project.version}</tag>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>java-hamcrest</artifactId>
            <version>${java-hamcrest.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>