<?xml version="1.0"?>
<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">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.enioka.jqm</groupId>
        <artifactId>jqm-all</artifactId>
        <version>3.5.1</version>
    </parent>
    <artifactId>jqm-integration-tests</artifactId>

    <name>${project.groupId}:${project.artifactId}</name>
    <url>http://jqm.readthedocs.org</url>
    <description>Test suite for the JQM engine + service</description>

    <properties>
        <argLine>-Xms256m -Xmx1024m -XX:MaxMetaspaceSize=512m --add-opens
            java.naming/javax.naming.spi=ALL-UNNAMED</argLine>
    </properties>

    <profiles>
        <!-- https://issues.apache.org/jira/browse/MDEP-187 -->
        <!-- Must disable unpack in M2E -->
        <!-- it means the external tests cannot run without CLI help -->
        <profile>
            <id>dev</id>
            <activation>
                <property>
                    <!-- Also disable this build when inside eclipse or vs code. -->
                    <name>m2e.version</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>

                        <executions>
                            <execution>
                                <id>unpack-full-server</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <plugins>
            <!-- Create ext and lib directories for tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>${plugin.dependency.version}</version>
                <configuration>
                    <skip>false</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>process-test-classes</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.hsqldb</groupId>
                                    <artifactId>hsqldb</artifactId>
                                    <version>${hsqldb.version}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.postgresql</groupId>
                                    <artifactId>postgresql</artifactId>
                                    <version>${postgresql.client.version}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.mysql</groupId>
                                    <artifactId>mysql-connector-j</artifactId>
                                    <version>${mysql.client.version}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.mariadb.jdbc</groupId>
                                    <artifactId>mariadb-java-client</artifactId>
                                    <version>${mariadb.client.version}</version>
                                </artifactItem>
                                <dependency>
                                    <groupId>com.ibm.db2</groupId>
                                    <artifactId>jcc</artifactId>
                                    <version>${db2.client.version}</version>
                                </dependency>
                                <artifactItem>
                                    <groupId>com.h2database</groupId>
                                    <artifactId>h2</artifactId>
                                    <version>${h2.version}</version>
                                </artifactItem>
                                <dependency>
                                    <groupId>com.oracle.database.jdbc</groupId>
                                    <artifactId>ojdbc8</artifactId>
                                    <version>${oracle.client.version}</version>
                                </dependency>

                            </artifactItems>
                            <outputDirectory>${project.basedir}/target/server/ext</outputDirectory>
                        </configuration>
                    </execution>

                    <!-- Needed for the external runner tests which start a full node -->
                    <execution>
                        <id>unpack-full-server</id>
                        <phase>process-test-sources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>

                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>jqm-service</artifactId>
                                    <version>${project.version}</version>
                                    <type>zip</type>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>${plugin.resources.version}</version>
                <executions>
                    <!-- Copy test payload XML files -->
                    <execution>
                        <id>copy-payloads</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/server/payloads</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/src/test/resources/payloads</directory>
                                    <filtering>false</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>

                    <!-- Copy (move) the server distribution to target root (to have a fixed name) -->
                    <execution>
                        <id>copy-server</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/server</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/target/jqm-${project.version}</directory>
                                    <filtering>false</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-server-config</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/server/conf</outputDirectory>
                            <overwrite>true</overwrite>
                            <resources>
                                <resource>
                                    <directory>${basedir}/src/test/resources/</directory>
                                    <filtering>false</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

    <dependencies>
        <!-- This project mostly tests the service JQM distribution -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>jqm-service</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>jqm-cli</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!-- Need the APIs not present in the service -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>jqm-api-client-jdbc</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>jqm-api-client-jersey</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>com.enioka.jqm</groupId>
            <artifactId>jqm-test-helpers</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- Tests helpers -->
        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
            <version>${jaxrs.api.version}</version>
            <scope>provided</scope>
        </dependency>        <!-- needed for exceptions -->
        <dependency>
            <groupId>jakarta.mail</groupId>
            <artifactId>jakarta.mail-api</artifactId>
            <version>${mail.api.version}</version>
        </dependency>
        <dependency> <!-- reference Jakarta Mail implementation -->
            <groupId>org.eclipse.angus</groupId>
            <artifactId>angus-mail</artifactId>
            <version>${mail.implem.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${commons.lang3.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- DB drivers for tests -->
        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <version>${hsqldb.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-jdbc</artifactId>
            <version>${pool.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.icegreen</groupId>
            <artifactId>greenmail-junit4</artifactId>
            <version>2.1.8</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
    </dependencies>
</project>
