<?xml version="1.0" encoding="UTF-8"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.mule.modules</groupId>
    <artifactId>mule-transport-amqp-studio</artifactId>
    <packaging>eclipse-repository</packaging>
    <parent>
        <artifactId>mule-transport-amqp-plugin-parent</artifactId>
        <groupId>org.mule.transports</groupId>
        <version>3.9.3</version>
    </parent>

    <properties>
        <mule.version>3.9.0</mule.version>
        <category>Select</category>
        <!-- The license path property is used by the studio-us-signer plugin -->
        <licensePath>${project.basedir}/LICENSE.md</licensePath>
        <mule.devkit.version>${mule.version}</mule.devkit.version>
        <devkit.studio.package.skip>true</devkit.studio.package.skip>
        <finalName>mule-transport-amqp-studio-${project.version}-studio-plugin</finalName>
        <updateSiteName>${finalName}</updateSiteName>
    </properties>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <configuration>
                    <skip>false</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-p2-publisher-plugin</artifactId>
                <version>${tycho-version}</version>
                <configuration>
                    <publishArtifacts>true</publishArtifacts>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-p2-repository-plugin</artifactId>
                <version>${tycho-version}</version>
                <configuration>
                    <finalName>${finalName}</finalName>
                    <compress>false</compress>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <configuration>
                            <tasks>
                                <echo message="unzipping update site to sign it" />
                                <unzip src="${project.build.directory}\${finalName}.zip" dest="${project.build.directory}\update-site" />
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!-- AMQP-54: Added as a workaround to install/deploy the update-site with the 'studio-plugin' classifier.
                For an unknown reason the tycho-p2-repository-plugin use the ${finalName} property in the package phase
                but then in the install phase the maven-install-plugin use mule-transport-amqp-studio-${version}.zip -->
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>${project.build.directory}\${updateSiteName}.zip</file>
                                    <type>zip</type>
                                    <classifier>studio-plugin</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <properties>
                <devkit.studio.package.skip>false</devkit.studio.package.skip>
                <updateSiteName>UpdateSite</updateSiteName>
            </properties>
            <id>update-site</id>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.mule.tooling</groupId>
                        <artifactId>studio-us-signer</artifactId>
                        <version>1.4.1</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>sign-us</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
