<?xml version="1.0" encoding="UTF-8"?>
<!--
   Copyright 2017 Decipher Technology Studios LLC

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>io.github.schereradi</groupId>
    <artifactId>vault-maven-plugin</artifactId>
    <version>1.1.1</version>
    <packaging>maven-plugin</packaging>

    <name>Vault Maven Plugin</name>
    <description>A plugin that supports retrieving values from HashiCorp Vault.</description>
    <url>https://github.com/schereradi/vault-maven-plugin</url>

    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:git@github.com:schereradi/vault-maven-plugin.git</connection>
        <developerConnection>scm:git:git@github.com:schereradi/vault-maven-plugin.git</developerConnection>
        <url>https://github.com/schereradi/vault-maven-plugin</url>
    </scm>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <developers>
        <developer>
            <name>Scherer Adrian</name>
            <organization>io.github.schereradi</organization>
            <email>scherer.adi@gmail.com</email>
        </developer>
    </developers>

    <properties>
        <docker.network>vault-maven-plugin-${maven.build.timestamp}</docker.network>
        <docker.nginx.host>nginx.docker</docker.nginx.host>
        <docker.vault.host>vault.docker</docker.vault.host>
        <docker.vault.token>6edb70bd-3398-1f42-d67e-b9db377223cd</docker.vault.token>
        <jacoco.integration.file>${project.build.directory}/jacoco-integration.exec</jacoco.integration.file>
        <jacoco.merged.file>${project.build.directory}/jacoco.exec</jacoco.merged.file>
        <jacoco.unit.file>${project.build.directory}/jacoco-unit.exec</jacoco.unit.file>
        <maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
        <maven.test.runOrder>hourly</maven.test.runOrder>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <version.bouncycastle.plugin>1.0.0</version.bouncycastle.plugin>
        <version.checkstyle.plugin>2.17</version.checkstyle.plugin>
        <version.compiler.plugin>3.8.1</version.compiler.plugin>
        <version.docker.plugin>0.20.1</version.docker.plugin>
        <version.failsafe.plugin>${version.surefire.plugin}</version.failsafe.plugin>
        <version.freemarker>2.3.23</version.freemarker>
        <version.guava>19.0</version.guava>
        <version.jacoco>0.8.7</version.jacoco>
        <version.jacoco.plugin>${version.jacoco}</version.jacoco.plugin>
        <version.java.source>1.8</version.java.source>
        <version.java.target>1.8</version.java.target>
        <version.javadoc.plugin>2.10.4</version.javadoc.plugin>
        <version.junit>4.12</version.junit>
        <version.maven>3.3.9</version.maven>
        <version.moby>1.0.0</version.moby>
        <version.nginx>1.11</version.nginx>
        <version.plugin.api>3.3.9</version.plugin.api>
        <version.plugin.annotations>3.5</version.plugin.annotations>
        <version.plugin.testing>3.3.0</version.plugin.testing>
        <version.plugin.plugin>3.5</version.plugin.plugin>
        <version.source.plugin>3.0.1</version.source.plugin>
        <version.surefire.plugin>2.19.1</version.surefire.plugin>
        <version.vault>0.6.5</version.vault>
        <version.vault.driver>5.1.0</version.vault.driver>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.bettercloud</groupId>
            <artifactId>vault-java-driver</artifactId>
            <version>${version.vault.driver}</version>
        </dependency>
        <dependency>
            <groupId>com.deciphernow</groupId>
            <artifactId>moby-dns</artifactId>
            <version>${version.moby}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${version.guava}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava-testlib</artifactId>
            <version>${version.guava}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${version.junit}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-artifact</artifactId>
            <version>${version.maven}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-compat</artifactId>
            <version>${version.maven}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-core</artifactId>
            <version>${version.maven}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-plugin-api</artifactId>
            <version>${version.plugin.api}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugin-testing</groupId>
            <artifactId>maven-plugin-testing-harness</artifactId>
            <version>${version.plugin.testing}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugin-tools</groupId>
            <artifactId>maven-plugin-tools-annotations</artifactId>
            <version>${version.plugin.annotations}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>${version.freemarker}</version>
        </dependency>
        <dependency>
            <groupId>org.jacoco</groupId>
            <artifactId>org.jacoco.agent</artifactId>
            <classifier>runtime</classifier>
            <version>${version.jacoco}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>${version.checkstyle.plugin}</version>
                <configuration>
                    <configLocation>checkstyle.xml</configLocation>
                    <consoleOutput>true</consoleOutput>
                    <encoding>UTF-8</encoding>
                    <linkXRef>false</linkXRef>
                </configuration>
                <executions>
                    <execution>
                        <id>checkstyle</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${version.compiler.plugin}</version>
                <configuration>
                    <source>${version.java.source}</source>
                    <target>${version.java.target}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${version.failsafe.plugin}</version>
                <configuration>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                    <runOrder>${maven.test.runOrder}</runOrder>
                    <includes>
                        <include>**/IntTest*.class</include>
                        <include>**/IntSpec*.class</include>
                    </includes>
                    <systemPropertyVariables>
                        <vault.host>${docker.nginx.host}</vault.host>
                        <vault.port>${docker.nginx.port}</vault.port>
                        <vault.token>${docker.vault.token}</vault.token>
                        <sun.net.spi.nameservice.provider.1>dns,moby</sun.net.spi.nameservice.provider.1>
                        <sun.net.spi.nameservice.provider.2>default</sun.net.spi.nameservice.provider.2>
                    </systemPropertyVariables>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>verify</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>${version.plugin.plugin}</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${version.surefire.plugin}</version>
                <configuration>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                    <runOrder>${maven.test.runOrder}</runOrder>
                    <includes>
                        <include>**/Test*.class</include>
                        <include>**/Spec*.class</include>
                    </includes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${version.jacoco.plugin}</version>
                <executions>
                    <execution>
                        <id>prepare-agent</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <destFile>${jacoco.unit.file}</destFile>
                            <sessionId>${artifactId}-unit-${maven.build.timestamp}</sessionId>
                        </configuration>
                    </execution>
                    <execution>
                        <id>prepare-agent-integration</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>prepare-agent-integration</goal>
                        </goals>
                        <configuration>
                            <destFile>${jacoco.integration.file}</destFile>
                            <sessionId>${artifactId}-integration-${maven.build.timestamp}</sessionId>
                        </configuration>
                    </execution>
                    <execution>
                        <id>merge</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>merge</goal>
                        </goals>
                        <configuration>
                            <destFile>${jacoco.merged.file}</destFile>
                            <fileSets>
                                <fileSet>
                                    <directory>${project.build.directory}</directory>
                                    <includes>
                                        <include>*.exec</include>
                                    </includes>
                                </fileSet>
                            </fileSets>
                        </configuration>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <dataFile>${jacoco.merged.file}</dataFile>
                        </configuration>
                    </execution>
                    <execution>
                        <id>check</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <rule>
                                    <element>BUNDLE</element>
                                    <limits>
                                        <limit>
                                            <counter>COMPLEXITY</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.75</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>deploy</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${version.javadoc.plugin}</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-source-plugin</artifactId>
                        <version>${version.source.plugin}</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>deploy-central</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.7</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.5</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
