<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright 2013 polyglotted.org

    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>
    <parent>
        <groupId>io.polyglotted</groupId>
        <artifactId>oss-parent</artifactId>
        <version>2.0.0</version>
    </parent>
    <artifactId>echo-app</artifactId>
    <version>1.0.0</version>
    <name>Echo App</name>
    <packaging>jar</packaging>

    <scm>
        <url>https://github.com/polyglotted/echo-app</url>
        <connection>scm:git:ssh://github.com/polyglotted/echo-app.git</connection>
        <developerConnection>scm:git:git+ssh://git@github.com/polyglotted/echo-app.git</developerConnection>
        <tag>echo-app-1.0.0</tag>
    </scm>
    <repositories>
        <repository>
            <id>sonatype-repository</id>
            <name>Sonatype Repository</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

    <properties>
        <slf4j.version>1.7.12</slf4j.version>
        <netty.version>4.0.30.Final</netty.version>
        <spring.version>4.2.0.RELEASE</spring.version>
        <lombok.version>1.16.4</lombok.version>
        <guava.version>18.0</guava.version>

        <launch.strategy>App</launch.strategy>
        <application.directory>/vol/applications/app</application.directory>
        <docker-maven.version>0.3.1</docker-maven.version>
        <applauncher.version>2.0.0</applauncher.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.polyglotted</groupId>
            <artifactId>app-launcher</artifactId>
            <version>${applauncher.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${guava.version}</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
            <version>${netty.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${slf4j.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <id>unpack-app-launcher</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>io.polyglotted</groupId>
                                    <artifactId>app-launcher</artifactId>
                                    <version>${applauncher.version}</version>
                                    <type>zip</type>
                                    <classifier>binary</classifier>
                                    <overWrite>true</overWrite>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${project.build.directory}/app-launcher</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-app-launch-config</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/config</outputDirectory>
                            <encoding>UTF-8</encoding>
                            <resources>
                                <resource>
                                    <directory>${project.build.directory}/app-launcher</directory>
                                    <includes>
                                        <include>bin/**</include>
                                        <include>etc/**</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-docker-config</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/docker</outputDirectory>
                            <encoding>UTF-8</encoding>
                            <resources>
                                <resource>
                                    <directory>${project.build.directory}/app-launcher/docker</directory>
                                    <includes>
                                        <include>Dockerfile</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-launcher</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/.idea/runConfigurations</outputDirectory>
                            <encoding>UTF-8</encoding>
                            <resources>
                                <resource>
                                    <directory>${project.build.directory}/app-launcher/launcher</directory>
                                    <includes>
                                        <include>app-idea.xml</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>override-with-src-etc</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/config/etc</outputDirectory>
                            <encoding>UTF-8</encoding>
                            <resources>
                                <resource>
                                    <directory>${basedir}/src/main/config/etc</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptors>
                        <descriptor>${project.build.directory}/app-launcher/templates/assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>${docker-maven.version}</version>
                <configuration>
                    <imageName>polyglotted/${project.artifactId}:${project.version}</imageName>
                    <dockerDirectory>${project.build.directory}/docker</dockerDirectory>
                    <resources>
                        <resource>
                            <targetPath>/</targetPath>
                            <directory>${project.build.directory}</directory>
                            <include>${project.artifactId}-${project.version}-binary.tar.gz</include>
                        </resource>
                    </resources>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
 </project>
