<?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-standalone-elasticsearch-parent</artifactId>
        <groupId>io.quarkus</groupId>
        <version>3.20.1</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

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

    <dependencies>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-core-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-backend-elasticsearch-common-deployment</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-hibernate-search-standalone-elasticsearch</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-vertx-http-dev-ui-spi</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-vertx-http-deployment-spi</artifactId>
        </dependency>

        <!-- test dependencies -->
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-junit5-internal</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-vertx-http-deployment</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-vertx-http-dev-ui-tests</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-compile</id>
                        <configuration>
                            <annotationProcessorPaths>
                                <path>
                                    <groupId>io.quarkus</groupId>
                                    <artifactId>quarkus-extension-processor</artifactId>
                                    <version>${project.version}</version>
                                </path>
                            </annotationProcessorPaths>
                        </configuration>
                    </execution>
                </executions>
            </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>
                                            <xpack.security.enabled>false</xpack.security.enabled>
                                            <ES_JAVA_OPTS>-Xms512m -Xmx512m</ES_JAVA_OPTS>
                                            <!-- Disable disk-based shard allocation thresholds:
                                                 in a single-node setup they just don't make sense,
                                                 and lead to problems on large disks with little space left.
                                                 See https://www.elastic.co/guide/en/elasticsearch/reference/8.8/modules-cluster.html#disk-based-shard-allocation
                                             -->
                                            <cluster.routing.allocation.disk.threshold_enabled>false</cluster.routing.allocation.disk.threshold_enabled>
                                            <!-- Disable some features that are not needed in our tests and just slow down startup -->
                                            <xpack.profiling.enabled>false</xpack.profiling.enabled>
                                            <xpack.monitoring.templates.enabled>false</xpack.monitoring.templates.enabled>
                                            <xpack.ml.enabled>false</xpack.ml.enabled>
                                            <xpack.watcher.enabled>false</xpack.watcher.enabled>
                                            <xpack.ent_search.enabled>false</xpack.ent_search.enabled>
                                            <stack.templates.enabled>false</stack.templates.enabled>
                                            <cluster.deprecation_indexing.enabled>false</cluster.deprecation_indexing.enabled>
                                            <indices.lifecycle.history_index_enabled>false</indices.lifecycle.history_index_enabled>
                                            <slm.history_index_enabled>false</slm.history_index_enabled>
                                        </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>30000</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>
