<?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">
    <parent>
        <groupId>org.mule.tests</groupId>
        <artifactId>mule-extensions-integration-tests</artifactId>
        <version>4.6.2</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>tooling-support-tests</artifactId>

    <properties>
        <javaModuleName>org.mule.test.tooling.support</javaModuleName>
        
        <surefire.args>
            -XX:+IgnoreUnrecognizedVMOptions
            --add-exports=org.mule.runtime.deployment/org.mule.runtime.module.deployment.internal=org.mule.test.infrastructure
            --add-exports=org.mule.runtime.deployment/org.mule.runtime.module.deployment.internal.processor=org.mule.test.infrastructure
            --add-exports=org.mule.runtime.deployment.model.impl/org.mule.runtime.module.deployment.impl.internal=org.mule.test.infrastructure
            --add-exports=org.mule.runtime.launcher/org.mule.runtime.module.launcher.coreextension=org.mule.test.infrastructure
            --add-exports=org.mule.runtime.memory.management/org.mule.runtime.internal.memory.management=org.mule.test.infrastructure
            --add-exports=org.mule.runtime.metadata.model.api/org.mule.metadata.internal.utils=org.mule.test.tooling.support
            --add-exports=org.mule.runtime.repository/org.mule.runtime.module.repository.internal=org.mule.test.infrastructure
            --add-exports=org.mule.runtime.tooling.support/org.mule.runtime.module.tooling.internal=org.mule.test.infrastructure
            ${surefire.args.base}
        </surefire.args>
        
        <formatterConfigPath>../formatter.xml</formatterConfigPath>
        <settingsFile>${java.io.tmpdir}/settings.xml</settingsFile>
        <testExtensionVersion>4.6.2</testExtensionVersion>
        <weave.service.location>services/weave</weave.service.location>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.mule.runtime</groupId>
            <artifactId>mule-module-tooling-support</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mule.tests</groupId>
            <artifactId>mule-tests-infrastructure</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mule.runtime</groupId>
            <artifactId>mule-module-launcher</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mule.tests</groupId>
            <artifactId>mule-tests-functional</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mule.tooling</groupId>
            <artifactId>tooling-support-test-extension</artifactId>
            <type>test-jar</type>
            <version>${testExtensionVersion}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mule</groupId>
            <artifactId>mule-maven-client-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>download-extensions</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>get</goal>
                        </goals>
                        <configuration>
                            <groupId>org.mule.tooling</groupId>
                            <artifactId>tooling-support-test-extension</artifactId>
                            <version>${testExtensionVersion}</version>
                            <classifier>mule-plugin</classifier>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-testCompile</id>
                        <configuration>
                            <compilerArgs>
                                <arg>--add-exports=org.mule.runtime.metadata.model.api/org.mule.metadata.internal.utils=org.mule.test.tooling.support</arg>
                            </compilerArgs>
                            <testRelease>11</testRelease>
                        </configuration>
                    </execution>
                    <execution>
                        <id>base-testCompile</id>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                        <configuration>
                            <testRelease>${javaReleaseVersion}</testRelease>
                            <!-- recompile everything for target VM except the module-info.java -->
                            <testExcludes>
                                <testExclude>module-info.java</testExclude>
                            </testExcludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <mule.version>${project.version}</mule.version>
                        <settings.file>${settingsFile}</settings.file>

                        <xmlApisLib>${xml-apis:xml-apis:jar}</xmlApisLib>
                        <apiAnnotationsLib>${org.mule.runtime:api-annotations:jar}</apiAnnotationsLib>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-weave-service</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.mule.services</groupId>
                                    <artifactId>mule-service-weave</artifactId>
                                    <version>${weaveVersion}</version>
                                    <classifier>mule-service</classifier>
                                    <outputDirectory>${project.build.directory}/${weave.service.location}</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>no-large-tests</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skipTests>true</skipTests>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>