<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.mule.tooling</groupId>
        <artifactId>mule-runtime-tooling-client-parent</artifactId>
        <version>4.0.0-FD.2</version>
    </parent>

    <artifactId>mule-agent-rest-client</artifactId>
    <name>Mule Runtime Tooling Client :: Mule Agent REST</name>
    <description>REST Client for Mule Agent Tooling Services</description>

    <properties>
        <formatterConfigPath>../formatter.xml</formatterConfigPath>
        <runtime.location>${project.build.directory}/runtimes</runtime.location>
        <mule.distribution.folder>mule-enterprise-standalone-${mule.version}</mule.distribution.folder>
        <mulePluginClassifier>mule-plugin</mulePluginClassifier>
    </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-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <skip>true</skip>
                    <systemProperties>
                        <property>
                            <name>MULE_HOME</name>
                            <value>${runtime.location}/${mule.distribution.folder}</value>
                        </property>
                    </systemProperties>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.19.1</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-junit47</artifactId>
                        <version>2.19.1</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <includes>
                        <include>**/*TestCase</include>
                    </includes>
                    <testFailureIgnore>false</testFailureIgnore>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptors>
                        <descriptor>src/main/assembly/zip.xml</descriptor>
                    </descriptors>
                    <appendAssemblyId>false</appendAssemblyId>
                    <attach>false</attach>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.mule.tools</groupId>
                <artifactId>mule-assembly-verifier</artifactId>
                <configuration>
                    <whitelist>src/main/assembly/assembly-whitelist.txt</whitelist>
                </configuration>
                <executions>
                    <execution>
                        <phase>verify</phase>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-all</artifactId>
                        <version>2.4.8</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.mule.runtime</groupId>
            <artifactId>mule-api</artifactId>
            <scope>provided</scope>
        </dependency>
        
        <dependency>
            <groupId>org.mule.runtime</groupId>
            <artifactId>mule-metadata-model-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.mule.runtime</groupId>
            <artifactId>mule-extensions-api-persistence</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.mule.tooling</groupId>
            <artifactId>mule-runtime-event-model</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.mule.tooling</groupId>
            <artifactId>mule-runtime-tooling-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-multipart</artifactId>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
        </dependency>

        <dependency>
            <groupId>com.mulesoft.agent</groupId>
            <artifactId>mule-agent-web-interface</artifactId>
            <version>${mule.agent.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>com.mulesoft.mule.runtime.modules</groupId>
                    <artifactId>mule-module-plugin-ee</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>joda-time</groupId>
                    <artifactId>joda-time</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.mulesoft.agent</groupId>
            <artifactId>mule-agent-api</artifactId>
            <version>${mule.agent.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>com.google.inject</groupId>
                    <artifactId>guice</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.sisu</groupId>
                    <artifactId>org.eclipse.sisu.inject</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.ning</groupId>
                    <artifactId>async-http-client</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.validation</groupId>
                    <artifactId>validation-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>org.mule.tooling</groupId>
            <artifactId>mule-runtime-process-controller</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <scope>test</scope>
        </dependency>

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

        <dependency>
            <groupId>org.mule.tooling</groupId>
            <artifactId>mule-runtime-tooling-tests-utils</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.icegreen</groupId>
            <artifactId>greenmail</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>ru.yandex.qatools.allure</groupId>
            <artifactId>allure-java-annotations</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>prepare-integration-tests</id>
            <activation>
                <property>
                    <name>skipPrepareIntegrationTests</name>
                    <value>!true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>2.8</version>
                        <executions>
                            <execution>
                                <id>unpack-mule-standalone</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>com.mulesoft.mule.distributions</groupId>
                                            <artifactId>mule-ee-distribution-standalone</artifactId>
                                            <version>${mule.version}</version>
                                            <type>tar.gz</type>
                                        </artifactItem>
                                    </artifactItems>
                                    <outputDirectory>${runtime.location}</outputDirectory>
                                    <overWriteReleases>true</overWriteReleases>
                                    <overWriteSnapshots>true</overWriteSnapshots>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-agent-mule</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>com.mulesoft.agent</groupId>
                                            <artifactId>mule-agent-plugin</artifactId>
                                            <version>${mule.agent.version}</version>
                                            <type>zip</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>
                                                ${runtime.location}/${mule.distribution.folder}/server-plugins/mule-agent-plugin/
                                            </outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                    <overWriteReleases>true</overWriteReleases>
                                    <overWriteSnapshots>true</overWriteSnapshots>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.8</version>
                        <executions>
                            <execution>
                                <id>configure-pristine-runtimes</id>
                                <phase>pre-integration-test</phase>
                                <configuration>
                                    <target>
                                        <copy file="${project.build.testOutputDirectory}/descriptors/mule-agent.yml" todir="${runtime.location}/${mule.distribution.folder}/conf/" overwrite="true" />
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
