<?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>
        <artifactId>togglz-project</artifactId>
        <groupId>org.togglz</groupId>
        <version>3.3.3</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>togglz-dynamodb</artifactId>
    <name>Togglz - DynamoDB integration</name>
    <description>Togglz - DynamoDB integration</description>

    <dependencies>
        <dependency>
            <groupId>org.togglz</groupId>
            <artifactId>togglz-core</artifactId>
        </dependency>

        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-dynamodb</artifactId>
            <version>1.12.321</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.13.4.2</version>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- download the dynamo local version -->
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>unpack-dynamodb-local</id>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.jcabi</groupId>
                                    <artifactId>DynamoDBLocal</artifactId>
                                    <version>2015-07-16</version>
                                    <type>zip</type>
                                    <outputDirectory>${project.build.directory}/dynamodb-dist</outputDirectory>
                                    <overWrite>false</overWrite>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>reserve-dynamodb-port</id>
                        <goals>
                            <goal>reserve-network-port</goal>
                        </goals>
                        <configuration>
                            <portNames>
                                <portName>dynamodblocal.port</portName>
                            </portNames>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.jcabi</groupId>
                <artifactId>jcabi-dynamodb-maven-plugin</artifactId>
                <version>0.10.1</version>
                <configuration>
                    <port>${dynamodblocal.port}</port>
                    <dist>${project.build.directory}/dynamodb-dist</dist>
                    <tables>
                        <table>${project.basedir}/src/test/dynamo/preexistingTable.json</table>
                    </tables>
                    <arguments>
                        <argument>-inMemory</argument>
                        <argument>-sharedDb</argument>
                    </arguments>
                </configuration>
                <executions>
                    <execution>
                        <id>dynamodb-integration-test</id>
                        <goals>
                            <goal>start</goal>
                            <goal>create-tables</goal>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <!-- No unit tests in this module so far. You should drop this plugin section when you add some :) -->
                    <skip>true</skip>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <dynamodb.port>${dynamodblocal.port}</dynamodb.port>
                    </systemPropertyVariables>
                </configuration>
                <version>2.22.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
