<?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.mulesoft.mule.distributions</groupId>
        <artifactId>mule-ee-distributions</artifactId>
        <version>4.4.0-20240821</version>
    </parent>
    <artifactId>mule-ee-distribution-standalone</artifactId>
    <packaging>pom</packaging>
    <name>Standalone Distribution</name>
    <description>Includes the Mule server with all of its APIs and internal modules</description>

    <properties>
        <standaloneStructureDir>${project.build.directory}/distribution-structure</standaloneStructureDir>
        <standaloneStructure>mule-standalone-structure</standaloneStructure>
        
        <libPatchesOutputDir>${project.build.directory}/lib/patches</libPatchesOutputDir>
        <muleArtifactsPatchesOutputDir>${libPatchesOutputDir}/mule-artifact-patches</muleArtifactsPatchesOutputDir>

        <formatterConfigPath>../formatter.xml</formatterConfigPath>
        <groovyAllVersion>2.4.19</groovyAllVersion>

        <mule.artifact.patches.bom.version>1.0.25</mule.artifact.patches.bom.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <!--
                             This has to happen early in the build lifecycle so that plugins running
                             later in the build lifecycle can work on the unpacked distro.
                             -->
                        <id>unpack-dependencies</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.mulesoft.mule.distributions</groupId>
                                    <artifactId>mule-config-files</artifactId>
                                    <version>${project.version}</version>
                                    <outputDirectory>${project.build.directory}/dependency-config-files</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.mule.distributions</groupId>
                                    <artifactId>${standaloneStructure}</artifactId>
                                    <version>${project.version}</version>
                                    <type>tar.gz</type>
                                    <outputDirectory>${standaloneStructureDir}</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.mulesoft.agent</groupId>
                                    <artifactId>agent-setup</artifactId>
                                    <version>${mule.agent.version}</version>
                                    <type>zip</type>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>tanukisoft</groupId>
                                    <artifactId>wrapper-delta-pack</artifactId>
                                    <version>${wrapperVersion}</version>
                                    <type>tar.gz</type>
                                    <outputDirectory>${project.build.directory}/wrapper</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-container-app-plugins-jar-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/plugins</outputDirectory>
                            <includeTypes>jar</includeTypes>
                            <includeGroupIds>
                                org.mule.modules,com.mulesoft.mule.modules
                            </includeGroupIds>
                            <includeClassifiers>mule-plugin</includeClassifiers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>${assembly.plugin.version}</version>
                <executions>
                    <execution>
                        <id>standalone</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <finalName>mule-enterprise-standalone-${project.version}</finalName>
                            <descriptors>
                                <descriptor>src/assembly/assembly.xml</descriptor>
                            </descriptors>
                            <appendAssemblyId>false</appendAssemblyId>
                            <tarLongFileMode>posix</tarLongFileMode>
                        </configuration>
                    </execution>
                    <execution>
                        <id>cumulative-patch</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <archive>
                                <manifest>
                                    <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                                    <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                                </manifest>
                                <manifestEntries>
                                    <Build-Revision>${buildNumber}</Build-Revision>
                                    <Build-Date>${timestamp}</Build-Date>
                                </manifestEntries>
                            </archive>
                            <finalName>mule-enterprise-standalone-${project.version}</finalName>
                            <descriptors>
                                <descriptor>src/assembly/assembly-patch.xml</descriptor>
                            </descriptors>
                            <appendAssemblyId>true</appendAssemblyId>
                            <tarLongFileMode>posix</tarLongFileMode>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.mulesoft.mule.distributions</groupId>
                        <artifactId>container-descriptor-handler</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>org.mule.tools</groupId>
                <artifactId>mule-assembly-verifier</artifactId>
                <configuration>
                    <skip>${skipVerifications}</skip>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <projectOutputFile>mule-enterprise-standalone-${project.version}.zip</projectOutputFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.gmaven</groupId>
                <artifactId>groovy-maven-plugin</artifactId>
                <version>2.1.1</version>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-all</artifactId>
                        <version>${groovyAllVersion}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <defaults>
                                <basedir>${project.basedir}</basedir>
                            </defaults>
                            <source>${project.basedir}/src/main/groovy/buildtools/GenerateModulesRepositoryInformation.groovy</source>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!--
                 We generate a full source bundle using the groovy plugin above. Do not
                 publish maven's autogenerated and empty sources jar of this module.
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <configuration>
                    <attach>false</attach>
                </configuration>
            </plugin>

            <plugin>
                <groupId>net.nicoulaj.maven.plugins</groupId>
                <artifactId>checksum-maven-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>artifacts</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <attachChecksums>true</attachChecksums>
                    <algorithms>
                        <algorithm>SHA-256</algorithm>
                    </algorithms>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
                <configuration>
                    <includes>
                        <include>**/*TestCase.java</include>
                    </includes>
                    <additionalClasspathElements>
                        <additionalClasspathElement>${basedir}/src/main/groovy</additionalClasspathElement>
                    </additionalClasspathElements>
                    <systemPropertyVariables>
                        <baseDir>${project.basedir} </baseDir>
                        <outputDir>${project.build.directory}</outputDir>
                    </systemPropertyVariables>
                </configuration>
                <executions>
                    <execution>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-build-distribution-metadata</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>${project.basedir}/target/BUILD.json</file>
                                    <type>json</type>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>

        <dependency>
            <groupId>com.mulesoft.mule.distributions</groupId>
            <artifactId>support-tools-installer</artifactId>
            <version>${project.version}</version>
            <type>zip</type>
        </dependency>

        <dependency>
            <groupId>com.mulesoft.mule.distributions</groupId>
            <artifactId>mule-runtime-impl-bom</artifactId>
            <version>${project.version}</version>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>org.mule.runtime</groupId>
            <artifactId>mule-module-reboot</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!-- add aspectj weaver dependency that was removed from spring-security-3.1 -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
        </dependency>

        <!-- Overwrite Jackson dependency with our own version -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-jsonSchema</artifactId>
        </dependency>

        <!-- Mule distribution structure -->
        <dependency>
            <groupId>org.mule.distributions</groupId>
            <artifactId>${standaloneStructure}</artifactId>
            <version>${project.version}</version>
            <type>tar.gz</type>
        </dependency>

        <!-- It's picking this up from CE and we have a new version for EE -->
        <dependency>
            <groupId>tanukisoft</groupId>
            <artifactId>wrapper</artifactId>
            <version>${wrapperVersion}</version>
        </dependency>

        <!-- API Gateway -->
        <dependency>
            <groupId>com.mulesoft.mule.distributions</groupId>
            <artifactId>api-gateway-bom-impl</artifactId>
            <version>${agw.version}</version>
            <type>pom</type>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.httpcomponents</groupId>
                    <artifactId>httpclient</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Mule Artifact patches -->
        <dependency>
            <groupId>com.mulesoft.mule.runtime.bom</groupId>
            <artifactId>mule-artifact-patches-bom</artifactId>
            <version>${mule.artifact.patches.bom.version}</version>
            <type>pom</type>
        </dependency>

		<!-- Test dependencies -->
        <dependency>
            <groupId>org.mule.tests</groupId>
            <artifactId>mule-tests-unit</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.objenesis</groupId>
                    <artifactId>objenesis</artifactId>
                </exclusion>
            </exclusions>
		</dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>${groovyAllVersion}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.mulesoft.mule.distributions</groupId>
            <artifactId>mule-config-files</artifactId>
            <version>${project.version}</version>
            <type>jar</type>
        </dependency>
    </dependencies>
</project>
