<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <parent>
        <groupId>net.spals.appbuilder</groupId>
        <artifactId>spals-appbuilder-parent</artifactId>
        <version>0.4.0</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <groupId>net.spals.appbuilder.plugins</groupId>
    <artifactId>spals-appbuilder-mapstore-mongodb-test</artifactId>
    <version>0.4.0</version>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>eu.codearte.catch-exception</groupId>
            <artifactId>catch-exception</artifactId>
        </dependency>
        <dependency>
            <groupId>eu.codearte.catch-exception</groupId>
            <artifactId>catch-throwable</artifactId>
        </dependency>
        <dependency>
            <groupId>io.opentracing</groupId>
            <artifactId>opentracing-mock</artifactId>
        </dependency>
        <dependency>
            <groupId>net.spals.appbuilder.plugins</groupId>
            <artifactId>spals-appbuilder-mapstore-mongodb</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>java-hamcrest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest_${scala.version}</artifactId>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>discover-mongodb-ip</id>
                        <goals>
                            <goal>local-ip</goal>
                        </goals>
                        <configuration>
                            <localIpProperty>mongodb.ip</localIpProperty>
                        </configuration>
                    </execution>
                    <execution>
                        <id>reserve-mongodb-port</id>
                        <goals>
                            <goal>reserve-network-port</goal>
                        </goals>
                        <configuration>
                            <portNames>
                                <portName>mongodb.port</portName>
                            </portNames>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <configuration>
                    <images>
                        <image>
                            <name>mongo:3.5</name>
                            <alias>mongodb</alias>
                            <run>
                                <ports>
                                    <port>mongodb.port:27017</port>
                                </ports>
                                <wait>
                                    <log>waiting for connections on port</log>
                                    <time>5000</time>
                                    <shutdown>500</shutdown>
                                </wait>
                            </run>
                        </image>
                    </images>
                    <skipRun>${skipTests}</skipRun>
                </configuration>
                <executions>
                    <execution>
                        <id>start-docker-containers</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop-docker-containers</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <environmentVariables>
                        <MONGODB_IP>${mongodb.ip}</MONGODB_IP>
                        <MONGODB_PORT>${mongodb.port}</MONGODB_PORT>
                    </environmentVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
