<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <groupId>io.quarkiverse.hibernatesearchextras</groupId>
        <artifactId>quarkus-hibernate-search-extras-integration-tests-parent</artifactId>
        <version>1.0.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>quarkus-integration-test-hibernate-search-orm-elasticsearch-aws</artifactId>
    <name>Quarkus - Hibernate Search Extras - Integration Tests - ORM + Elasticsearch - AWS Integration</name>

    <properties>
        <elasticsearch.hosts>localhost:9200</elasticsearch.hosts>
        <elasticsearch.protocol>http</elasticsearch.protocol>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-resteasy</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-hibernate-search-orm-elasticsearch</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkiverse.hibernatesearchextras</groupId>
            <artifactId>quarkus-hibernate-search-orm-elasticsearch-aws</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-jdbc-h2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>compile</scope>
        </dependency>

        <!-- test dependencies -->
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-junit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-test-h2</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.commons</groupId>
                    <artifactId>commons-lang3</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.github.tomakehurst</groupId>
            <artifactId>wiremock-jre8</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- Necessary for Wiremock for some reason -->
        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemProperties>
                        <elasticsearch.hosts>${elasticsearch.hosts}</elasticsearch.hosts>
                        <elasticsearch.protocol>${elasticsearch.protocol}</elasticsearch.protocol>
                    </systemProperties>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <systemProperties>
                        <elasticsearch.hosts>${elasticsearch.hosts}</elasticsearch.hosts>
                        <elasticsearch.protocol>${elasticsearch.protocol}</elasticsearch.protocol>
                    </systemProperties>
                </configuration>
            </plugin>
            <plugin>
                <groupId>io.quarkus</groupId>
                <artifactId>quarkus-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.38.0</version>
                <configuration>
                    <images>
                        <image>
                            <name>${elasticsearch.image}</name>
                            <alias>elasticsearch</alias>
                            <run>
                                <env>
                                    <discovery.type>single-node</discovery.type>
                                </env>
                                <ports>
                                    <port>9200:9200</port>
                                </ports>
                                <log>
                                    <prefix>Elasticsearch: </prefix>
                                    <date>default</date>
                                    <color>cyan</color>
                                </log>
                                <wait>
                                    <http>
                                        <url>http://localhost:9200</url>
                                        <method>GET</method>
                                        <status>200</status>
                                    </http>
                                    <time>20000</time>
                                </wait>
                            </run>
                        </image>
                    </images>
                    <allContainers>true</allContainers>
                </configuration>
                <executions>
                    <execution>
                        <id>docker-start</id>
                        <phase>process-test-classes</phase>
                        <goals>
                            <goal>stop</goal>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>docker-stop</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
