<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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.extensions</groupId>
        <artifactId>mule-core-modules-parent</artifactId>
        <version>1.1.9</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <groupId>org.mule.modules</groupId>
    <artifactId>mule-json-module</artifactId>
    <version>2.5.5</version>
    <packaging>mule-extension</packaging>
    <name>Json Module</name>

    <properties>
        <!--TODO [W-20002231](https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE00002NnXksYAF/view)
        networknt version can't be upgraded to 1.3.0 since it breaks backwards compatibility.
                  version can't be upgraded to intermediate versions since the error messages changed.
                  https://github.com/networknt/json-schema-validator/pull/536
        -->
        <com.networknt.version>1.0.87</com.networknt.version>
        <commons.pool2.version>2.13.1</commons.pool2.version>
        <commons.lang3.version>3.20.0</commons.lang3.version>
        <exec.maven.plugin.version>3.6.3</exec.maven.plugin.version>
        <file.connector.version>1.5.5</file.connector.version>
        <guava.version>33.5.0-jre</guava.version>
        <jackson.annotations.version>2.20</jackson.annotations.version>
        <jackson.databind.version>${jackson.version}</jackson.databind.version>
        <jackson.dataformat.yaml.version>${jackson.version}</jackson.dataformat.yaml.version>
        <jackson.version>2.20.1</jackson.version>
        <jacoco.version>0.8.14</jacoco.version>
        <jakarta.mail.version>2.0.2</jakarta.mail.version>
        <json.schema.validation.version>2.2.14</json.schema.validation.version>
        <license.maven.plugin.version>4.6</license.maven.plugin.version>
        <licensePath>LICENSE_HEADER.txt</licensePath>
        <licenseYear>2024</licenseYear>
        <maven.invoker.version>3.9.1</maven.invoker.version>
        <maven.repo.local>${settings.localRepository}</maven.repo.local>
        <maven.help.plugin.version>3.5.1</maven.help.plugin.version>
        <mule.sdk.api.version>0.12.0</mule.sdk.api.version>
        <mule.extensions.shade.plugin.version>1.0.4</mule.extensions.shade.plugin.version>
        <mule.shaders.module.version>1.0.0</mule.shaders.module.version>
        <copy.rename.maven.plugin.version>1.0.1</copy.rename.maven.plugin.version>
        <mtf.javaopts></mtf.javaopts>
        <mtf.tools.version>1.2.0</mtf.tools.version>
        <mulesoftLicenseVersion>1.4.0</mulesoftLicenseVersion>
        <munit.extensions.maven.plugin.version>1.6.1</munit.extensions.maven.plugin.version>
        <munit.version>3.6.3</munit.version>
        <org.mozilla.rhino.version>1.7.15</org.mozilla.rhino.version>
        <settings.file>${java.io.tmpdir}/effective-settings.xml</settings.file>
        <!-- SonarQube exclusions -->
        <sonar.coverage.exclusions>
            **/internal/cleanup/JsonModuleResourceReleaser.java,
            **/ClassUtils.java,
            **/SystemPropertyUtils.java
        </sonar.coverage.exclusions>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.mule.sdk</groupId>
            <artifactId>mule-sdk-api</artifactId>
            <version>${mule.sdk.api.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.databind.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson.annotations.version}</version>
        </dependency>
        <dependency>
            <groupId>org.mozilla</groupId>
            <artifactId>rhino</artifactId>
            <version>${org.mozilla.rhino.version}</version>
        </dependency>
        <dependency>
            <groupId>com.github.java-json-tools</groupId>
            <artifactId>json-schema-validator</artifactId>
            <version>${json.schema.validation.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-annotations</artifactId>
                </exclusion>
                <exclusion>
                        <groupId>com.fasterxml.jackson.dataformat</groupId>
                        <artifactId>jackson-dataformat-yaml</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.guava</groupId>
                    <artifactId>guava</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.mail</groupId>
                    <artifactId>mailapi</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.mozilla</groupId>
                    <artifactId>rhino</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.networknt</groupId>
            <artifactId>json-schema-validator</artifactId>
            <version>${com.networknt.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.commons</groupId>
                    <artifactId>commons-lang3</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.sun.mail</groupId>
            <artifactId>jakarta.mail</artifactId>
            <version>${jakarta.mail.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-pool2</artifactId>
            <version>${commons.pool2.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${commons.lang3.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${guava.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-yaml</artifactId>
            <version>${jackson.dataformat.yaml.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>${exec.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <id>build-mule-shaders-module</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <workingDirectory>mule-shaders-module</workingDirectory>
                            <executable>mvn</executable>
                            <arguments>
                                <argument>install</argument>
                                <argument>-Dmaven.repo.local=${maven.repo.local}</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.mulesoft.munit</groupId>
                <artifactId>munit-extensions-maven-plugin</artifactId>
                <version>${munit.extensions.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <id>test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <minMuleVersionConfig>CONNECTOR</minMuleVersionConfig>
                    <argLines>
                            <argLine>${jacocoArgLine}</argLine>
                    </argLines>
                    <environmentVariables>
                        <!-- Toggles the JDK17 style flag -->
                        <!-- ugly hack -->
                        <_JAVA_OPTIONS>
                            -XX:+PrintCommandLineFlags
                        </_JAVA_OPTIONS>
                    </environmentVariables>
                    <runtimeConfiguration>
                        <discoverRuntimes>
                            <product>EE</product>
                            <minMuleVersion>${minVersion}</minMuleVersion>
                            <includeSnapshots>false</includeSnapshots>
                        </discoverRuntimes>
                    </runtimeConfiguration>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.github.java-json-tools</groupId>
                        <artifactId>json-schema-validator</artifactId>
                        <version>${json.schema.validation.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>com.mulesoft.munit</groupId>
                        <artifactId>munit-runner</artifactId>
                        <version>${munit.version}</version>
                        <classifier>mule-plugin</classifier>
                    </dependency>
                    <dependency>
                        <groupId>com.mulesoft.munit</groupId>
                        <artifactId>munit-tools</artifactId>
                        <version>${munit.version}</version>
                        <classifier>mule-plugin</classifier>
                    </dependency>
                    <dependency>
                        <groupId>com.mulesoft.munit</groupId>
                        <artifactId>mtf-tools</artifactId>
                        <version>${mtf.tools.version}</version>
                        <classifier>mule-plugin</classifier>
                    </dependency>
                    <dependency>
                        <groupId>org.mule.connectors</groupId>
                        <artifactId>mule-file-connector</artifactId>
                        <version>${file.connector.version}</version>
                        <classifier>mule-plugin</classifier>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.version}</version>
                <executions>
                    <execution>
                        <id>prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <destFile>${session.executionRootDirectory}/target/jacoco.exec</destFile>
                            <append>true</append>
                            <propertyName>jacocoArgLine</propertyName>
                        </configuration>
                    </execution>

                    <!-- Generate HTML report -->
                    <execution>
                        <id>report</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <dataFile>${session.executionRootDirectory}/target/jacoco.exec</dataFile>
                            <excludes>
                                <!-- Exclude test utilities only -->
                                <exclude>**/internal/cleanup/JsonModuleResourceReleaser*</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.mule.runtime.plugins</groupId>
                <artifactId>mule-extensions-shade-plugin</artifactId>
                <version>${mule.extensions.shade.plugin.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>org.mule.modules</groupId>
                        <artifactId>mule-shaders-module</artifactId>
                        <version>${mule.shaders.module.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>com.github.java-json-tools</groupId>
                        <artifactId>json-schema-validator</artifactId>
                        <version>${json.schema.validation.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <createDependencyReducedPom>false</createDependencyReducedPom>
                    <shaderHint>ReflectiveAccessShader</shaderHint>
                    <artifactSet>
                        <includes>
                            <include>com.github.java-json-tools:*</include>
                        </includes>
                    </artifactSet>
                    <relocations>
                        <relocation>
                            <pattern>com.github.fge</pattern>
                            <shadedPattern>org.mule.module.json.internal.shaded.com.github.fge</shadedPattern>
                        </relocation>
                    </relocations>
                    <transformers>
                        <transformer implementation="org.mule.module.shaders.api.ReflectiveAccessShaderTransformer">
                            <members>
                                <classMember>
                                    <className>com.github.fge.jackson.JsonNodeReader</className>
                                    <memberName>BUNDLE</memberName>
                                </classMember>
                                <classMember>
                                    <className>com.github.fge.jsonschema.core.report.ProcessingMessage</className>
                                    <memberName>BUNDLE</memberName>
                                </classMember>
                                <classMember>
                                    <className>com.github.fge.msgsimple.load.MessageBundles</className>
                                    <memberName>BUNDLES</memberName>
                                </classMember>
                                <classMember>
                                    <className>com.github.fge.msgsimple.bundle.MessageBundle</className>
                                    <memberName>providers</memberName>
                                </classMember>
                                <classMember>
                                    <className>com.github.fge.msgsimple.provider.LoadingMessageSourceProvider</className>
                                    <memberName>service</memberName>
                                </classMember>
                            </members>
                        </transformer>
                    </transformers>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.coderplus.maven.plugins</groupId>
                <artifactId>copy-rename-maven-plugin</artifactId>
                <version>${copy.rename.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <id>backup-shaded</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <sourceFile>${project.build.directory}/${project.artifactId}-${project.version}-mule-plugin.jar</sourceFile>
                            <destinationFile>${project.build.directory}/shaded-${project.artifactId}-${project.version}-mule-plugin.jar</destinationFile>
                        </configuration>
                    </execution>
                    <execution>
                        <id>restore-unshaded</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <sourceFile>${project.build.directory}/original-${project.artifactId}-${project.version}-mule-plugin.jar</sourceFile>
                            <destinationFile>${project.build.directory}/${project.artifactId}-${project.version}-mule-plugin.jar</destinationFile>
                            <overWrite>true</overWrite>
                        </configuration>
                    </execution>
                    <execution>
                        <id>restore-shaded</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <sourceFile>${project.build.directory}/shaded-${project.artifactId}-${project.version}-mule-plugin.jar</sourceFile>
                            <destinationFile>${project.build.directory}/${project.artifactId}-${project.version}-mule-plugin.jar</destinationFile>
                            <overWrite>true</overWrite>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>${license.maven.plugin.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>com.mulesoft.license</groupId>
                        <artifactId>license</artifactId>
                        <version>${mulesoftLicenseVersion}</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <header>${licensePath}</header>
                    <properties>
                        <year>${licenseYear}</year>
                    </properties>
                    <includes>
                        <include>**/*.java</include>
                    </includes>
                    <mapping>
                        <java>SLASHSTAR_STYLE</java>
                    </mapping>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-help-plugin</artifactId>
                <version>${maven.help.plugin.version}</version>
                <executions>
                    <execution>
                        <phase>process-test-resources</phase>
                        <id>copy-settings</id>
                        <goals>
                            <goal>effective-settings</goal>
                        </goals>
                        <configuration>
                            <output>${settings.file}</output>
                            <showPasswords>true</showPasswords>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-invoker-plugin</artifactId>
                <version>${maven.invoker.version}</version>
                <configuration>
                    <skipInvocation>${skipIts}</skipInvocation>
                    <debug>false</debug>
                    <streamLogs>true</streamLogs>
                    <noLog>true</noLog>
                    <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
                    <properties>
                        <maven.settings.local>${settings.file}</maven.settings.local>
                        <tita.artifact>${project.build.directory}/shaded-${project.artifactId}-${project.version}-mule-plugin.jar</tita.artifact>
                    </properties>
                    <filterProperties>
                        <project.version>${project.version}</project.version>
                    </filterProperties>
                </configuration>
                <executions>
                    <execution>
                        <id>tita-tests</id>
                        <phase>install</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <inherited>false</inherited>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>mule-plugin</id>
            <name>Mule Repository</name>
            <url>https://repository.mulesoft.org/nexus/content/repositories/public/</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>mule-plugin</id>
            <name>Mule Repository</name>
            <url>https://repository.mulesoft.org/nexus/content/repositories/public/</url>
        </pluginRepository>
    </pluginRepositories>
</project>
