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

    <parent>
        <groupId>org.mule.runtime.plugins</groupId>
        <artifactId>mule-plugins-maven-plugin-parent</artifactId>
        <version>1.11.2</version>
    </parent>

    <artifactId>mule-module-parent-pom-holder</artifactId>
    <packaging>pom</packaging>

    <properties>
        <parent.pom.groupId>org.mule.extensions</parent.pom.groupId>
        <parent.pom.artifactId>mule-modules-parent</parent.pom.artifactId>
    </properties>

    <build>
        <resources>
            <resource>
                <directory>src/main/pom</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>filter-pom</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>resources</goal>
                        </goals>
                        <configuration>
                            <escapeString>\</escapeString>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <executions>
                    <execution>
                        <id>install-parent-pom</id>
                        <!-- Make sure the parent poms are available if just running tests -->
                        <phase>package</phase>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                        <configuration>
                            <file>${project.build.outputDirectory}/pom.xml</file>
                            <groupId>${parent.pom.groupId}</groupId>
                            <artifactId>${parent.pom.artifactId}</artifactId>
                            <version>${project.version}</version>
                            <packaging>pom</packaging>
                            <generatePom>false</generatePom>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <executions>
                    <execution>
                        <id>deploy-parent-pom</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy-file</goal>
                        </goals>
                        <configuration>
                            <file>${project.build.outputDirectory}/pom.xml</file>
                            <groupId>${parent.pom.groupId}</groupId>
                            <artifactId>${parent.pom.artifactId}</artifactId>
                            <version>${project.version}</version>
                            <packaging>pom</packaging>
                            <repositoryId>${project.distributionManagement.snapshotRepository.id}</repositoryId>
                            <url>${project.distributionManagement.snapshotRepository.url}</url>
                            <generatePom>false</generatePom>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-deploy-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>deploy-parent-pom</id>
                                <phase>deploy</phase>
                                <goals>
                                    <goal>deploy-file</goal>
                                </goals>
                                <configuration>
                                    <file>${project.build.outputDirectory}/pom.xml</file>
                                    <groupId>${parent.pom.groupId}</groupId>
                                    <artifactId>${parent.pom.artifactId}</artifactId>
                                    <version>${project.version}</version>
                                    <packaging>pom</packaging>
                                    <repositoryId>${project.distributionManagement.repository.id}</repositoryId>
                                    <url>${project.distributionManagement.repository.url}</url>
                                    <generatePom>false</generatePom>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>

