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

    <parent>
        <groupId>com.atlassian.streams</groupId>
        <artifactId>streams-parent</artifactId>
        <version>3.1.0</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.atlassian.streams</groupId>
    <artifactId>streams-remote-jira-plugin</artifactId>
    <packaging>jar</packaging>
    <name>JIRA Streams Remote Plugin</name>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.streams</groupId>
            <artifactId>streams-remote</artifactId>
            <version>${pom.version}</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <!-- Unpack the reference implementation WAR into the target directory -->
                    <execution>
                        <id>unpack-remote-plugin</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.atlassian.streams</groupId>
                                    <artifactId>streams-remote</artifactId>
                                    <type>jar</type>
                                    <outputDirectory>
                                        ${project.build.outputDirectory}
                                    </outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <!-- This task may or may not need to be done, the problem is, maven won't overwrite
                            the atlassian-plugin.xml from streams remote if its timestamp is newer than our
                            one, so we'll manually do it to ensure it gets done. -->
                        <id>overwrite-atlassian-plugins</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <copy todir="${project.build.outputDirectory}" overwrite="true" file="src/main/resources/atlassian-plugin.xml" />
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
