<?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">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-reactive-pg-client-parent</artifactId>
        <version>1.3.2.Final-redhat-00001</version>
        <relativePath>../</relativePath>
    </parent>

    <artifactId>quarkus-reactive-pg-client-deployment</artifactId>

    <name>Quarkus - Reactive PostgreSQL Client - Deployment</name>

    <dependencies>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-reactive-datasource-deployment</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-vertx-deployment</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-reactive-pg-client</artifactId>
        </dependency>

        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-resteasy</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-junit5-internal</artifactId>
            <scope>test</scope>
            <version>1.3.2.Final</version>
        </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-postgresql</id>
            <activation>
                <property>
                    <name>test-postgresql</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>docker-postgresql</id>
            <activation>
                <property>
                    <name>docker</name>
                </property>
            </activation>
            <properties>
                <postgres.url>jdbc:postgresql://localhost:5431/hibernate_orm_test</postgres.url>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <configuration>
                            <images>
                                <image>
                                    <name>postgres:10.5</name>
                                    <alias>postgresql</alias>
                                    <run>
                                        <env>
                                            <POSTGRES_USER>hibernate_orm_test</POSTGRES_USER>
                                            <POSTGRES_PASSWORD>hibernate_orm_test</POSTGRES_PASSWORD>
                                            <POSTGRES_DB>hibernate_orm_test</POSTGRES_DB>
                                        </env>
                                        <ports>
                                            <port>5431:5432</port>
                                        </ports>
                                        <wait>
                                            <tcp>
                                                <mode>mapped</mode>
                                                <ports>
                                                    <port>5432</port>
                                                </ports>
                                            </tcp>
                                            <time>10000</time>
                                        </wait>
                                    </run>
                                </image>
                            </images>
                            <!--Stops all postgres:10.5 images currently running, not just those we just started.
                              Useful to stop processes still running from a previously failed integration test run -->
                            <allContainers>true</allContainers>
                        </configuration>
                        <executions>
                            <execution>
                                <id>docker-start</id>
                                <phase>compile</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>
        </profile>
    </profiles>

</project>
