<?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>com.mulesoft.mule.framework</groupId>
        <artifactId>mule-framework-tests</artifactId>
        <version>1.2.3</version>
    </parent>

    <artifactId>mule-framework-integration-tests</artifactId>

    <name>Mule Framework Integration Tests</name>

    <properties>
        <keepServicesAliveAfterLastFrameworkClosed>true</keepServicesAliveAfterLastFrameworkClosed>

        <frameworkTestBomVersion>${project.version}</frameworkTestBomVersion>

        <!-- TODO W-10624034 (MMP-581) - remove this and define apps in a module  -->
        <settingsFile>${java.io.tmpdir}/effective-settings.xml</settingsFile>
    </properties>

    <build>
        <testResources>
            <testResource>
                <filtering>true</filtering>
                <directory>${basedir}/src/test/resources</directory>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <configuration>
                    <propertiesEncoding>UTF-8</propertiesEncoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>properties</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>unpack-services-bundle</id>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <phase>generate-test-resources</phase>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.mulesoft.mule.framework</groupId>
                                    <artifactId>mule-framework-static-requirements-bundle</artifactId>
                                    <type>zip</type>
                                    <version>${project.version}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.mulesoft.mule.framework</groupId>
                                    <artifactId>mule-framework-static-requirements-reduced-bundle</artifactId>
                                    <type>zip</type>
                                    <version>${project.version}</version>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${project.build.directory}/dependency</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>predownload-jira-connector-1.2.8</id>
                        <goals>
                            <goal>get</goal>
                        </goals>
                        <phase>generate-test-resources</phase>
                        <configuration>
                            <artifact>com.mulesoft.connectors:mule4-jira-connector:1.2.8:jar:mule-plugin</artifact>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- This plugin copies the effective maven settings to a file so it can be used by MavenTestUtils. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-help-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>process-test-resources</phase>
                        <id>copy-settings</id>
                        <goals>
                            <goal>effective-settings</goal>
                        </goals>
                        <configuration>
                            <output>${settingsFile}</output>
                            <showPasswords>true</showPasswords>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <!-- Avoid regenerating the services classloaders for every muleFwk created by tests, which cause the tests to take longer -->
                        <mule.framework.keepServicesAliveAfterLastFrameworkClosed>${keepServicesAliveAfterLastFrameworkClosed}</mule.framework.keepServicesAliveAfterLastFrameworkClosed>

                        <!-- TODO W-10624034 (MMP-581) - remove this and define apps in a module  -->
                        <mule.test.maven.artifacts.dir>noDir</mule.test.maven.artifacts.dir>
                        <settings.file>${settingsFile}</settings.file>
                        <maven.home>${maven.home}</maven.home>
                        <mule.framework.services.bundle.dir>${project.build.directory}/dependency/mule-framework-static-requirements-bundle-${project.version}/services</mule.framework.services.bundle.dir>
                        <mule.framework.services.reduced.bundle.dir>${project.build.directory}/dependency/mule-framework-static-requirements-reduced-bundle-${project.version}/services</mule.framework.services.reduced.bundle.dir>
                        <custom.local.repo>${project.build.directory}/custom-repo</custom.local.repo>
                        <project.build.directory>${project.build.directory}</project.build.directory>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <!-- Create a "custom" `ModuleRepository` to be available for tests -->
                        <id>build-module-repository</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>com.mulesoft.mule.framework.classpath.ModuleRepositoryGenerator</mainClass>
                            <arguments>
                                <argument>${project.build.outputDirectory}</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>validate-polymule-tests</id>
                        <phase>package</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>com.mulesoft.mule.framework.integration.tests.validation.PolyMuleValidator</mainClass>
                            <classpathScope>test</classpathScope>
                            <arguments>
                                <argument>${project.build.testOutputDirectory}</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>com.mulesoft.mule.framework</groupId>
            <artifactId>mule-framework-bom</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.mulesoft.mule.framework</groupId>
            <artifactId>mule-framework-classpath</artifactId>
            <version>${project.version}</version>
        </dependency>
        <!-- Added to signal the `mule-framework-maven-plugin` is needed in this artifact tests -->
        <dependency>
            <groupId>com.mulesoft.mule.framework</groupId>
            <artifactId>mule-framework-maven-plugin</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>*</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.ow2.asm</groupId>
            <artifactId>asm</artifactId>
        </dependency>

        <!-- test dependencies -->
        <dependency>
            <groupId>com.mulesoft.mule.framework</groupId>
            <artifactId>mule-framework-service-diet-scheduler</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.mulesoft.mule.framework</groupId>
            <artifactId>mule-framework-static-requirements-bundle</artifactId>
            <type>zip</type>
            <version>${project.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>*</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.mulesoft.mule.framework</groupId>
            <artifactId>mule-framework-test-utils</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.mulesoft.mule.framework</groupId>
            <artifactId>mule-framework-test-connectors-resolver</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mule.weave</groupId>
            <artifactId>runtime</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mule.tests</groupId>
            <artifactId>mule-tests-allure</artifactId>
            <version>${muleVersion}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-junit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.wiremock</groupId>
            <artifactId>wiremock</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- TODO W-13712868 - remove if support for Java 8 is dropped -->
        <dependency>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
            <!-- This is needed only for jdk8, the required classes from here -->
            <!-- are already available in the jdk on versions 11+ -->
            <scope>provided</scope>
        </dependency>
    </dependencies>

</project>
