<?xml version="1.0" encoding="UTF-8"?>
<!--

     Copyright 2017 Adobe.

     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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.adobe.testing</groupId>
    <artifactId>s3mock</artifactId>
    <version>1.1.4</version>
    <packaging>jar</packaging>

    <name>S3 Mock</name>
    <description>S3 mock implementation to be used for hermetic testing</description>
    <url>https://www.github.com/adobe/S3Mock</url>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
        <relativePath />
    </parent>

    <scm>
        <connection>scm:git:https://github.com/adobe/S3Mock.git</connection>
        <developerConnection>scm:git:https://github.com/adobe/S3Mock.git</developerConnection>
        <url>http://github.com/adobe/S3Mock/tree/master</url>
        <tag>1.1.4</tag>
    </scm>

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

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <start-class>com.adobe.testing.s3mock.S3MockApplication</start-class>

        <openjdk.version>8u131</openjdk.version>
        <aws.version>1.11.241</aws.version>
        <logback.version>1.2.3</logback.version>
        <jcloverslf4j.version>1.7.6</jcloverslf4j.version>
        <commons-codec.version>1.10</commons-codec.version>
        <xstream.version>1.4.10</xstream.version>
        <commons-io.version>2.5</commons-io.version>
        <joda-time.version>2.9.9</joda-time.version>
        <jackson.version>2.8.6</jackson.version>
        <spring-oxm.version>4.3.6.RELEASE</spring-oxm.version>

        <!-- docker stuff -->
        <docker.image.name>adobe/s3mock</docker.image.name>
        <docker-maven-plugin.version>0.21.0</docker-maven-plugin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
        </dependency>

        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>
        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
            <version>${xstream.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commons-io.version}</version>
        </dependency>

        <!-- Test Dependencies -->

        <!-- JUnit Rule dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-s3</artifactId>
            <version>${aws.version}</version>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.6.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <encoding>${project.build.sourceEncoding}</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>2.5.3</version>
                    <configuration>
                        <autoVersionSubmodules>true</autoVersionSubmodules>
                        <goals>deploy -DskipTests -Prelease -Ppush-docker-image</goals>
                        <preparationGoals>clean install -DskipTests</preparationGoals>
                        <tagNameFormat>@{project.version}</tagNameFormat>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>1.6.8</version>
                    <extensions>true</extensions>
                    <configuration>
                        <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        <nexusUrl>
                            https://oss.sonatype.org/
                        </nexusUrl>
                        <serverId>ossrh</serverId>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <configuration>
                        <systemPropertyVariables>
                            <it.s3mock.host>${docker.host.ip}</it.s3mock.host>
                            <it.s3mock.port_https>${it.s3mock.port_https}</it.s3mock.port_https>
                        </systemPropertyVariables>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>io.fabric8</groupId>
                    <artifactId>docker-maven-plugin</artifactId>
                    <version>${docker-maven-plugin.version}</version>
                    <configuration>
                        <verbose>true</verbose>
                        <images>
                            <image>
                                <alias>s3mock</alias>
                                <name>${docker.image.name}</name>
                                <build>
                                    <from>openjdk:${openjdk.version}-jre-alpine</from>
                                    <workdir>/opt/service</workdir>
                                    <ports>
                                        <port>9090</port>
                                        <port>9191</port>
                                    </ports>
                                    <entryPoint>
                                        <exec>
                                            <arg>java</arg>
                                            <arg>-Xmx128m</arg>
                                            <arg>-Djava.security.egd=file:/dev/./urandom</arg>
                                            <arg>-Xmx128m</arg>
                                            <arg>-jar</arg>
                                            <arg>${project.build.finalName}.jar</arg>
                                        </exec>
                                    </entryPoint>
                                    <assembly>
                                        <basedir>/opt</basedir>
                                        <inline>
                                            <fileSets>
                                                <fileSet>
                                                    <directory>
                                                        ${project.build.directory}
                                                    </directory>
                                                    <includes>
                                                        <include>
                                                            ${project.build.finalName}.jar
                                                        </include>
                                                    </includes>
                                                    <outputDirectory>service</outputDirectory>
                                                    <filtered>false</filtered>
                                                    <fileMode>755</fileMode>
                                                </fileSet>
                                            </fileSets>
                                        </inline>
                                        <mode>dir</mode>
                                    </assembly>
                                    <tags>
                                        <tag>${project.version}</tag>
                                        <tag>latest</tag>
                                    </tags>
                                </build>
                                <run>
                                    <log>
                                        <enabled>true</enabled>
                                    </log>
                                    <ports>
                                        <port>+docker.host.ip:it.s3mock.port_http:9090</port>
                                        <port>+docker.host.ip:it.s3mock.port_https:9191</port>
                                    </ports>
                                    <wait>
                                        <http>
                                            <url>
                                                http://${docker.host.ip}:${it.s3mock.port_http}/favicon.ico
                                            </url>
                                        </http>
                                        <time>30000</time>
                                    </wait>
                                    <env>
                                        <validKmsKeys>
                                            arn:aws:kms:us-east-1:1234567890:key/valid-test-key-ref
                                        </validKmsKeys>
                                        <initialBuckets>bucket-a, bucket-b</initialBuckets>
                                    </env>
                                </run>
                            </image>
                        </images>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>com.mycila</groupId>
                    <artifactId>license-maven-plugin</artifactId>
                    <version>3.0</version>
                    <configuration>
                        <header>${project.basedir}/etc/license-template.txt</header>
                        <strictCheck>true</strictCheck>
                        <excludes>
                            <exclude>.idea/**</exclude>
                            <exclude>.springBeans</exclude>
                            <exclude>**/*.jks</exclude>
                            <exclude>**/sample*.txt</exclude>
                            <exclude>LICENSE</exclude>
                            <exclude>AUTHORS</exclude>
                            <exclude>README.md</exclude>
                            <exclude>.travis.yml</exclude>
                            <exclude>.travis/**</exclude>
                            <exclude>CONTRIBUTING.md</exclude>
                            <exclude>.gitattributes</exclude>
                            <exclude>.gitignore</exclude>
                            <exclude>src/main/resources/banner.txt</exclude>
                        </excludes>
                        <mapping>
                            <java>SLASHSTAR_STYLE</java>
                        </mapping>
                    </configuration>
                </plugin>
                <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>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
                <executions>
                    <execution>
                        <id>javadoc</id>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>sources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <attach>false</attach>
                </configuration>
            </plugin>
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>build-docker-image</id>
                        <phase>package</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>start-docker-image</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop-docker-image</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>push-docker-image</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>tag-docker-image-commit-id</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>push</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>release</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-gpg-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <!-- required metadata for publishing the Maven artifacts -->
    <organization>
        <name>Adobe</name>
        <url>https://www.adobe.com</url>
    </organization>

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

    <developers>
        <developer>
            <name>Andreas Gudian</name>
            <email>gudian@adobe.com</email>
            <organization>Adobe</organization>
            <organizationUrl>https://www.adobe.com</organizationUrl>
        </developer>
        <developer>
            <name>Timo Eckhardt</name>
            <email>eckhardt@adobe.com</email>
            <organization>Adobe</organization>
            <organizationUrl>https://www.adobe.com</organizationUrl>
        </developer>
    </developers>
</project>
