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

    <artifactId>amp-launcher</artifactId>
    <packaging>bundle</packaging>
    <name>Cloudsoft Application Management Platform Launcher</name>
    <description>
        This project builds on the brooklyn-launcher to give a CLI for Cloudsoft AMP.
    </description>

    <parent>
        <groupId>io.cloudsoft.amp</groupId>
        <artifactId>amp-parent</artifactId>
        <version>2.0.0-M1</version>  <!-- AMP_VERSION -->
        <relativePath>../pom.xml</relativePath>
    </parent>

    <dependencies>
        <dependency>
            <groupId>io.brooklyn</groupId>
            <artifactId>brooklyn-cli</artifactId>
            <version>${brooklyn.version}</version>
        </dependency>
        <dependency>
            <groupId>io.cloudsoft.amp</groupId>
            <artifactId>amp-jsgui</artifactId>
            <version>${project.version}</version>
            <type>war</type>
        </dependency>

        <dependency>
            <groupId>io.brooklyn</groupId>
            <artifactId>brooklyn-logback-xml</artifactId>
            <version>${brooklyn.version}</version>
            <!-- optional so that this project has logging; dependencies may redeclare or supply their own -->
            <optional>true</optional>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>io.brooklyn</groupId>
            <artifactId>brooklyn-test-support</artifactId>
            <scope>test</scope>
            <version>${brooklyn.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <!-- explode brooklyn-launcher and merge with our code, overwriting brooklyn.war as we do so -->
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <!-- this can fail in eclipse trying to copy _from_ target/classes.
                                         see http://jira.codehaus.org/browse/MDEP-259 -->
                                    <groupId>io.brooklyn</groupId>
                                    <artifactId>brooklyn-launcher</artifactId>
                                    <version>${brooklyn.version}</version>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>target/classes</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <!-- this can fail in eclipse trying to copy _from_ target/classes.
                                         see http://jira.codehaus.org/browse/MDEP-259 -->
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>amp-jsgui</artifactId>
                                    <version>${project.version}</version>
                                    <type>war</type>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>target/classes</outputDirectory>
                                    <destFileName>brooklyn.war</destFileName>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <configuration>
                    <instructions>
                        <Include-Resource>{maven-resources}, target/classes/brooklyn.war</Include-Resource>
                        <Bundle-Activator>brooklyn.launcher.Activator</Bundle-Activator>
                        <Main-class>brooklyn.launcher.Main</Main-class>
                    </instructions>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-site-plugin</artifactId>
                <configuration>
                    <generateReports>false</generateReports>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
