<?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>1.0-SNAPSHOT</version>
    </parent>

    <artifactId>mule-agent-rest-client</artifactId>
    <version>4.0-SNAPSHOT</version>
    <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>
        <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>
                            <skip>${skipTests}</skip>
                        </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>
                            <skip>${skipTests}</skip>
                            <overWriteReleases>true</overWriteReleases>
                            <overWriteSnapshots>true</overWriteSnapshots>
                        </configuration>
                    </execution>
                    <execution>
                        <id>get-extensions</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.mule.modules</groupId>
                                    <artifactId>mule-module-db</artifactId>
                                    <version>${mule.version}</version>
                                    <classifier>${mulePluginClassifier}</classifier>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/extensions</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.mule.modules</groupId>
                                    <artifactId>mule-module-email</artifactId>
                                    <version>${mule.version}</version>
                                    <classifier>${mulePluginClassifier}</classifier>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/extensions</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${project.build.directory}/dependencies</outputDirectory>
                            <useBaseVersion>true</useBaseVersion>
                            <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" />

                                <delete file="${runtime.location}/${mule.distribution.folder}/lib/mule/mmc-agent-api-${mule.version}.jar" />
                                <delete file="${runtime.location}/${mule.distribution.folder}/lib/mule/mmc-agent-impl-${mule.version}.jar" />
                            </target>
                            <skip>${skipTests}</skip>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <packaging>jar</packaging>
                    <version>${mule.version}</version>
                    <localRepositoryPath>${runtime.location}/${mule.distribution.folder}/lib/mule/repository</localRepositoryPath>
                </configuration>
                <executions>
                    <execution>
                        <id>install-db-extension-into-mule-repository</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                        <configuration>
                            <file>${project.build.directory}/extensions/mule-module-db-${mule.version}-${mulePluginClassifier}.jar</file>
                            <groupId>org.mule.modules</groupId>
                            <artifactId>mule-module-db</artifactId>
                            <classifier>${mulePluginClassifier}</classifier>
                        </configuration>
                    </execution>
                    <execution>
                        <id>install-email-extension-into-mule-repository</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                        <configuration>
                            <file>${project.build.directory}/extensions/mule-module-email-${mule.version}-${mulePluginClassifier}.jar</file>
                            <groupId>org.mule.modules</groupId>
                            <artifactId>mule-module-email</artifactId>
                            <classifier>${mulePluginClassifier}</classifier>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <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</groupId>
            <artifactId>mule-api</artifactId>
            <scope>provided</scope>
        </dependency>
        
        <dependency>
            <groupId>org.mule</groupId>
            <artifactId>mule-metadata-model-api</artifactId>
            <scope>provided</scope>
        </dependency>

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

        <dependency>
            <groupId>org.mule.tooling</groupId>
            <artifactId>mule-runtime-tooling-api</artifactId>
            <version>${project.parent.version}</version>
            <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.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>
    </dependencies>
</project>
