<?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>
        <artifactId>quarkus-hibernate-search-orm-elasticsearch-parent</artifactId>
        <groupId>io.quarkus</groupId>
        <version>1.12.0.Final</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>quarkus-hibernate-search-orm-elasticsearch-deployment</artifactId>
    <name>Quarkus - Hibernate Search - ORM + Elasticsearch - Deployment</name>

    <dependencies>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-core-deployment</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-hibernate-orm-deployment</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-elasticsearch-rest-client-common-deployment</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-hibernate-search-orm-elasticsearch</artifactId>
        </dependency>

        <!-- test dependencies -->
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-junit5-internal</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-jdbc-h2-deployment</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-test-h2</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>io.quarkus</groupId>
                            <artifactId>quarkus-extension-processor</artifactId>
                            <version>${project.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>


    <profiles>
        <profile>
            <id>test-elasticsearch</id>
            <activation>
                <property>
                    <name>test-containers</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skip>false</skip>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>docker-elasticsearch</id>
            <activation>
                <property>
                    <name>start-containers</name>
                </property>
            </activation>
            <properties>
                <elasticsearch.hosts>localhost:9200</elasticsearch.hosts>
                <elasticsearch.protocol>http</elasticsearch.protocol>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <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>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>docker-prune</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>${docker-prune.location}</executable>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
