<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-integration-tests-parent</artifactId>
        <version>1.2.1.Final</version>
    </parent>

    <artifactId>quarkus-integration-test-maven</artifactId>

    <name>Quarkus - Integration Tests - Maven tooling</name>

    <dependencies>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-test-maven</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-bom-descriptor-json</artifactId>
            <version>${project.version}</version>
            <type>json</type>
            <exclusions>
                <exclusion>
                    <groupId>*</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-maven-plugin</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>
    </dependencies>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
            <testResource>
                <directory>src/it</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>io.quarkus</groupId>
                <artifactId>quarkus-platform-descriptor-json-plugin</artifactId>
                <version>${project.version}</version>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>validate-extensions-json</goal>
                        </goals>
                        <configuration>
                            <jsonGroupId>io.quarkus</jsonGroupId>
                            <jsonArtifactId>quarkus-bom-descriptor-json</jsonArtifactId>
                            <jsonVersion>${project.version}</jsonVersion>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-invoker-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
                    <cloneClean>true</cloneClean>
                    <settingsFile>src/it/settings.xml</settingsFile>
                    <postBuildHookScript>verify</postBuildHookScript>
                    <addTestClassPath>true</addTestClassPath>
                    <skipInvocation>${skipTests}</skipInvocation>
                    <streamLogs>true</streamLogs>
                    <invokerPropertiesFile>invoker.properties</invokerPropertiesFile>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-tests</id>
                        <goals>
                            <goal>install</goal>
                            <goal>run</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>io.quarkus</groupId>
                        <artifactId>quarkus-platform-descriptor-json</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>io.quarkus</groupId>
                        <artifactId>quarkus-platform-descriptor-resolver-json</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <!--suppress MavenModelInspection -->
                        <maven.home>${maven.home}</maven.home>
                        <maven.repo>${settings.localRepository}</maven.repo>
                        <project.version>${project.version}</project.version>
                    </systemPropertyVariables>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <systemPropertyVariables>
                        <!--suppress MavenModelInspection -->
                        <maven.home>${maven.home}</maven.home>
                        <maven.repo>${settings.localRepository}</maven.repo>
                        <project.version>${project.version}</project.version>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>native-image</id>
            <activation>
                <property>
                    <name>native</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <systemPropertyVariables>
                                <!--suppress MavenModelInspection -->
                                <maven.home>${maven.home}</maven.home>
                                <maven.repo>${settings.localRepository}</maven.repo>
                                <project.version>${project.version}</project.version>

                                <!-- add a system property that can be used by JUnit to determine whether a native image can be built -->
                                <quarkus.test.native>true</quarkus.test.native>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>

                </plugins>
            </build>
        </profile>
    </profiles>
</project>
