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

    <parent>
        <groupId>net.streamok</groupId>
        <artifactId>streamok-service</artifactId>
        <version>0.0.0</version>
    </parent>

    <artifactId>streamok-service-metrics</artifactId>
    <name>${project.artifactId}</name>

    <dependencies>
        <dependency>
            <groupId>net.streamok</groupId>
            <artifactId>streamok-fiber-node</artifactId>
            <version>0.0.0</version>
        </dependency>

        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-unit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <properties>
        <!-- General build rules -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>

        <!-- Plugins versions -->
        <docker-maven-plugin.version>0.15.9</docker-maven-plugin.version>
        <groovy-eclipse-batch.version>2.4.3-01</groovy-eclipse-batch.version>
        <groovy-eclipse-compiler.version>2.9.2-01</groovy-eclipse-compiler.version>
        <groovydoc-maven-plugin.version>1.3</groovydoc-maven-plugin.version>
        <maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
        <maven-gpg-plugin.version>1.5</maven-gpg-plugin.version>
        <maven-javadoc-plugin.version>2.10.4</maven-javadoc-plugin.version>
        <maven-release-plugin.version>2.5.2</maven-release-plugin.version>
        <maven-source-plugin.version>2.4</maven-source-plugin.version>
        <maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
        <nexus-staging-maven-plugin.version>1.6.5</nexus-staging-maven-plugin.version>
        <spring-boot.version>1.4.1.RELEASE</spring-boot.version>

        <!-- Docker configuration -->
        <mainClass>org.eclipse.kapua.locator.spring.KapuaApplication</mainClass>
        <image.target>${project.artifactId}</image.target>
        <maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format>
        <timestamp>${maven.build.timestamp}</timestamp>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>io.fabric8</groupId>
                    <artifactId>docker-maven-plugin</artifactId>
                    <version>${docker-maven-plugin.version}</version>
                    <configuration>
                        <images>
                            <image>
                                <name>smolok/${image.target}</name>
                                <build>
                                    <from>smolok/fatjar:${project.version}</from>
                                    <tags>
                                        <tag>latest</tag>
                                        <tag>${project.version}</tag>
                                        <tag>${timestamp}</tag>
                                    </tags>
                                </build>
                            </image>
                        </images>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.servicemix.tooling</groupId>
                    <artifactId>depends-maven-plugin</artifactId>
                    <version>${depends-maven-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>generate-depends-file</id>
                            <goals>
                                <goal>generate-depends-file</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring-boot.version}</version>
                    <executions>
                        <execution>
                            <configuration>
                                <classifier>fat</classifier>
                                <mainClass>${mainClass}</mainClass>
                            </configuration>
                            <goals>
                                <goal>repackage</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven-surefire-plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <compilerId>groovy-eclipse-compiler</compilerId>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-eclipse-batch</artifactId>
                        <version>${groovy-eclipse-batch.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-eclipse-compiler</artifactId>
                        <version>${groovy-eclipse-compiler.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>${maven-release-plugin.version}</version>
                <configuration>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <releaseProfiles>docker,deploy,release</releaseProfiles>
                    <goals>deploy</goals>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-eclipse-compiler</artifactId>
                <version>${groovy-eclipse-compiler.version}</version>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- Profile for only building Docker images during build process. -->
        <profile>
            <id>docker-build-only</id>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-plugin</artifactId>
                            <configuration>
                                <systemProperties>
                                    <test-profile>docker</test-profile>
                                </systemProperties>
                            </configuration>
                        </plugin>
                        <plugin>
                            <groupId>io.fabric8</groupId>
                            <artifactId>docker-maven-plugin</artifactId>
                            <executions>
                                <execution>
                                    <id>build</id>
                                    <phase>install</phase>
                                    <goals>
                                        <goal>build</goal>
                                    </goals>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>

        <!-- Profile for building and publishing Docker images during build process. -->
        <profile>
            <id>docker</id>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>io.fabric8</groupId>
                            <artifactId>docker-maven-plugin</artifactId>
                            <executions>
                                <execution>
                                    <id>build</id>
                                    <phase>install</phase>
                                    <goals>
                                        <goal>build</goal>
                                    </goals>
                                </execution>
                                <execution>
                                    <id>push</id>
                                    <phase>install</phase>
                                    <goals>
                                        <goal>push</goal>
                                    </goals>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>

        <!-- Profile used only during deploy. -->
        <profile>
            <id>deploy</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.bluetrainsoftware.maven</groupId>
                        <artifactId>groovydoc-maven-plugin</artifactId>
                        <version>${groovydoc-maven-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-docs</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>attach-docs</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${maven-javadoc-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>${maven-source-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>${nexus-staging-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Profile used only during release process. -->
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${maven-gpg-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <pluginRepositories>
        <pluginRepository>
            <!-- Groovy Maven plugin tries to download the artifacts from the dead Codehaus repository. -->
            <id>codehaus.org</id>
            <url>http://repository.codehaus.org</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <enabled>false</enabled>
            </releases>
        </pluginRepository>
    </pluginRepositories>

</project>
