<?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">
    <parent>
        <groupId>com.knecon.fforesight</groupId>
        <artifactId>platform-docker-dependency</artifactId>
        <version>0.1.0</version>
        <relativePath/>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>persistence-service-image-v1</artifactId>
    <groupId>com.iqser.red.service</groupId>
    <version>2.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <properties>
        <service.server>persistence-service-server-v1</service.server>
        <platform.jar>${service.server}.jar</platform.jar>
        <docker.skip.push>false</docker.skip.push>
        <docker.image.name>${docker.image.prefix}/${service.server}</docker.image.name>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>download-platform-jar</id>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>copy</goal>
                            </goals>
                            <configuration>
                                <artifactItems>
                                    <dependency>
                                        <groupId>${project.groupId}</groupId>
                                        <artifactId>${service.server}</artifactId>
                                        <version>${project.version}</version>
                                        <type>jar</type>
                                        <overWrite>true</overWrite>
                                        <destFileName>${platform.jar}</destFileName>
                                    </dependency>
                                </artifactItems>
                                <outputDirectory>${docker.build.directory}</outputDirectory>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>io.fabric8</groupId>
                    <artifactId>docker-maven-plugin</artifactId>
                    <configuration>
                        <images>
                            <image>
                                <name>${docker.image.name}</name>
                                <build>
                                    <dockerFileDir>${docker.build.directory}</dockerFileDir>
                                    <args>
                                        <PLATFORM_JAR>${platform.jar}</PLATFORM_JAR>
                                    </args>
                                    <tags>
                                        <tag>${docker.image.version}</tag>
                                        <tag>latest</tag>
                                    </tags>
                                </build>
                            </image>
                        </images>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>
