<?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>

    <name>Sage Intacct Connector - Mule 4</name>
    <description>Sage Intacct is a cloud based midsize enterprise ERP platform focused on delivering solutions for the core financials space.</description>

    <groupId>com.mulesoft.composer.connectors</groupId>
    <artifactId>mule4-sage-intacct-composer-connector</artifactId>
    <version>1.1.2-DEV2</version>
    <packaging>mule-extension</packaging>

    <parent>
        <groupId>com.mulesoft.connectivity</groupId>
        <artifactId>rest-connector-commons-parent-pom</artifactId>
        <version>0.1.0-alpha.2</version>
    </parent>

    <properties>
        <!-- rest-connector-commons-parent-pom matches Maven Plugin versions therefore we have to override this to avoid using this pom project.version -->
        <rest-connector-commons-exported-packages-maven-plugin.version>${project.parent.version}</rest-connector-commons-exported-packages-maven-plugin.version>
        <citizen-platform-connectors-models-maven-plugin.version>${project.parent.version}</citizen-platform-connectors-models-maven-plugin.version>
        <rest.connector.commons.shortName>sageIntacct</rest.connector.commons.shortName>
        <vertx.version>4.2.7</vertx.version>
        <allureJunitVersion>2.13.10</allureJunitVersion>
        <mockito-core.version>2.21.0</mockito-core.version>
        <mule-file-connector.version>1.2.0</mule-file-connector.version>
        <commons-lang3.version>3.12.0</commons-lang3.version>
        <jackson-databind.version>2.13.4.1</jackson-databind.version>
        <rest.connector.commons.allowList>com.mulesoft.connectors.sageintacct.api.metadata</rest.connector.commons.allowList>
        <mule-http-connector.version>1.6.0</mule-http-connector.version>
        <configuration.files.s3.folder>${project.artifactId}</configuration.files.s3.folder>
        <configuration.files.vault.secret.engine>connector-credentials</configuration.files.vault.secret.engine>
        <connector.maven.plugin.version>3.0.2</connector.maven.plugin.version>
    </properties>

    <dependencies>
        <!-- Needed for transforming XML file into POJO (used in MD) -->
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>${jaxb-api.version}</version>
        </dependency>
        <!-- Needed for operation with strings -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${commons-lang3.version}</version>
        </dependency>
        <!-- Needed for paginated operations -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson-databind.version}</version>
        </dependency>
        <!-- JUnit Dependencies -->
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito-core.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <!-- Added, because the connector-maven-plugin wants to download the file credential resource in the
        project.getTestResources() folder. This plugin gets the first test resource folder that the project has configured.
        The problem with that is that our parent pom adds two resources folder and the first one is dw, which we dont have created
        yet. So as a workaround we have to override the order. Should be removed after newer version of parent pom. -->
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
            <testResource>
                <directory>src/test/dw</directory>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>com.mulesoft.munit</groupId>
                <artifactId>munit-extensions-maven-plugin</artifactId>
                <version>${munit-extensions-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>test</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <phase>integration-test</phase>
                    </execution>
                </executions>
                <configuration combine.self="override">
                    <systemPropertyVariables>
                        <munit.test.timeout>600000</munit.test.timeout>
                    </systemPropertyVariables>
                    <runtimeVersion>4.4.0</runtimeVersion>
                    <runtimeProduct>MULE_EE</runtimeProduct>
                    <argLines>
                        <argLine>
                            -Dcom.mulesoft.dw.stacksize=2048
                        </argLine>
                        <argLine>
                            -javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/${jacoco.version}/org.jacoco.agent-${jacoco.version}-runtime.jar=destfile=${session.executionRootDirectory}/target/jacoco-munit.exec
                        </argLine>
                    </argLines>
                </configuration>
                <dependencies>
                    <!-- MUnit Dependencies -->
                    <dependency>
                        <groupId>org.mule.connectors</groupId>
                        <artifactId>mule-file-connector</artifactId>
                        <version>${mule-file-connector.version}</version>
                        <classifier>mule-plugin</classifier>
                    </dependency>
                    <dependency>
                        <groupId>org.mule.connectors</groupId>
                        <artifactId>mule-http-connector</artifactId>
                        <version>${mule-http-connector.version}</version>
                        <classifier>mule-plugin</classifier>
                    </dependency>
                </dependencies>
            </plugin>
            <!-- Custom-made plugin that retrieves the configuration files from an S3 bucket. -->
            <plugin>
                <groupId>com.mulesoft.connectors.maven</groupId>
                <artifactId>connector-maven-plugin</artifactId>
                <version>${connector.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <id>get-configuration-files</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>get-configuration-files</goal>
                        </goals>
                        <configuration>
                            <folder>${configuration.files.s3.folder}</folder>
                            <vaultBucket>${configuration.files.vault.secret.engine}</vaultBucket>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
