<?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>
        <artifactId>atlassian-whisper-parent</artifactId>
        <groupId>com.atlassian.whisper</groupId>
        <version>1.0.6</version>
    </parent>

    <artifactId>tests</artifactId>
    <packaging>pom</packaging>

    <modules>
        <module>pageobjects</module>
        <module>integration-tests</module>
        <module>integration-tests-jira</module>
    </modules>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.atlassian.whisper</groupId>
                <artifactId>whisper-delivery</artifactId>
                <version>${project.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>

            <!--configure Delivery mock for integration tests-->
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <executions>
                        <execution>
                            <goals>
                                <!--required for ${com.atlassian.whisper:whisper-delivery:jar} to work-->
                                <goal>properties</goal>
                            </goals>
                            <configuration>
                                <skip>${skipTests}</skip>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>1.5.0</version>
                    <executions>
                        <execution>
                            <id>delivery-mock-start</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>exec</goal>
                            </goals>
                            <configuration>
                                <executable>java</executable>
                                <!-- optional -->
                                <async>true</async>
                                <asyncDestroyOnShutdown>true</asyncDestroyOnShutdown>
                                <arguments>
                                    <argument>-Dserver.port=${delivery.port}</argument>
                                    <argument>-Dspring.application.admin.enabled=true</argument>
                                    <argument>-Dspring.profiles.active=inmemory</argument>
                                    <argument>-jar</argument>
                                    <!-- ignore: IntelliJ error might be ignored as property is resolved by dependency:properties goal-->
                                    <argument>${com.atlassian.whisper:whisper-delivery:jar}</argument>
                                </arguments>
                                <skip>${skipTests}</skip>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring.boot.version}</version>
                    <executions>
                        <execution>
                            <id>delivery-mock-stop</id>
                            <goals>
                                <goal>stop</goal>
                            </goals>
                            <configuration>
                                <skip>${skipTests}</skip>
                            </configuration>
                        </execution>
                    </executions>
                    <configuration>
                        <includes>
                            <include>
                                <groupId>com.atlassian.whisper</groupId>
                                <artifactId>whisper-delivery</artifactId>
                            </include>
                        </includes>
                        <mainClass>org.springframework.boot.loader.JarLauncher</mainClass>
                        <fork>true</fork>
                        <jvmArguments>-Dserver.port=${delivery.port} -Dspring.application.admin.enabled=true -Dspring.profiles.active=inmemory -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5008</jvmArguments>
                        <skip>${skipTests}</skip>
                    </configuration>
                </plugin>

            </plugins>
        </pluginManagement>
    </build>
</project>