<?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.fidesmo</groupId>
    <artifactId>fdsm</artifactId>
    <version>18.10.01</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.version.windows>18.10.01.0</project.version.windows>
    </properties>

    <!-- Necessary metadata for Maven Central -->
    <name>FDSM utility</name>
    <description>Swiss Army Knife for working with Fidesmo devices and Fidesmo API</description>
    <url>https://developer.fidesmo.com</url>

    <licenses>
        <license>
            <name>MIT</name>
            <url>https://github.com/fidesmo/fdsm/blob/master/LICENSE</url>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:git://github.com/fidesmo/fdsm.git</connection>
        <developerConnection>scm:git:ssh://github.com:fidesmo/fdsm.git</developerConnection>
        <url>http://github.com/fidesmo/fdsm/tree/master</url>
    </scm>

    <developers>
        <developer>
            <name>Martin Paljak</name>
            <email>martin.paljak@fidesmo.com</email>
            <organization>Fidesmo AB</organization>
            <organizationUrl>https://www.fidesmo.com</organizationUrl>
            <roles>
                <role>maintainer</role>
            </roles>
        </developer>
    </developers>

    <!-- Build information -->
    <dependencies>
        <!-- CLI -->
        <dependency>
            <groupId>net.sf.jopt-simple</groupId>
            <artifactId>jopt-simple</artifactId>
            <version>5.0.4</version>
            <optional>true</optional>
        </dependency>
        <!-- CAP parsing -->
        <dependency>
            <groupId>com.github.martinpaljak</groupId>
            <artifactId>capfile</artifactId>
            <version>18.09.25.1</version>
        </dependency>
        <!-- Card reader access -->
        <dependency>
            <groupId>com.github.martinpaljak</groupId>
            <artifactId>apdu4j</artifactId>
            <version>18.06.25.2</version>
        </dependency>
        <!-- API access: HTTP -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.6</version>
        </dependency>
        <!-- API access: JSON -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.9.7</version>
        </dependency>
        <!-- Util -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.6</version>
        </dependency>
        <!-- Simple logging for the CLI -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.25</version>
            <optional>true</optional>
        </dependency>
        <!-- Parsing GlobalPlatform response TLV -->
        <dependency>
            <groupId>com.payneteasy</groupId>
            <artifactId>ber-tlv</artifactId>
            <version>1.0-8</version>
        </dependency>
    </dependencies>

    <distributionManagement>
        <repository>
            <id>ossrh-fidesmo</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <profiles>
        <profile>
            <id>sign</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</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>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh-fidesmo</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>2.4</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>2.10.4</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.akathist.maven.plugins.launch4j</groupId>
                        <artifactId>launch4j-maven-plugin</artifactId>
                        <version>1.7.22</version>
                        <executions>
                            <execution>
                                <id>fdsm-exe</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>launch4j</goal>
                                </goals>
                                <configuration>
                                    <headerType>console</headerType>
                                    <outfile>target/fdsm.exe</outfile>
                                    <jar>target/fdsm.jar</jar>
                                    <errTitle>fdsm</errTitle>
                                    <classPath>
                                        <mainClass>com.fidesmo.fdsm.Main</mainClass>
                                    </classPath>
                                    <jre>
                                        <minVersion>1.8.0</minVersion>
                                    </jre>
                                    <versionInfo>
                                        <fileVersion>${project.version.windows}</fileVersion>
                                        <txtFileVersion>${project.version}</txtFileVersion>
                                        <fileDescription>Fidesmo utility</fileDescription>
                                        <copyright>(C) 2018 - present Fidesmo AB</copyright>
                                        <productVersion>${project.version.windows}</productVersion>
                                        <txtProductVersion>${project.version}</txtProductVersion>
                                        <productName>fdsm</productName>
                                        <internalName>fdsm</internalName>
                                        <originalFilename>fdsm.exe</originalFilename>
                                    </versionInfo>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <resources>
            <resource>
                <directory>target/generated-resources</directory>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.6.0</version> <executions>
                    <execution>
                        <id>git-version</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <executable>git</executable>
                    <outputFile>target/generated-resources/com/fidesmo/fdsm/version.txt</outputFile>
                    <arguments>
                        <argument>describe</argument>
                        <argument>--tags</argument>
                        <argument>--always</argument>
                        <argument>--long</argument>
                        <argument>--dirty</argument>
                    </arguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <debug>true</debug>
                    <debuglevel>lines,vars,source</debuglevel>
                    <compilerArgs>
                        <arg>-Xlint:deprecation</arg>
                        <arg>-Xlint:unchecked</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <finalName>fdsm</finalName>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.fidesmo.fdsm.Main</mainClass>
                                </transformer>
                            </transformers>
                            <artifactSet>
                                <excludes>
                                    <exclude>org.bouncycastle:*</exclude>
                                    <exclude>com.googlecode.json-simple:*</exclude>
                                </excludes>
                            </artifactSet>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                        <exclude>META-INF/maven/**</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
