<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright 2014-2015 by Cloudsoft Corporation Limited

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<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>
        <artifactId>brooklyn-clocker-parent</artifactId>
        <groupId>io.brooklyn.clocker</groupId>
        <version>0.8.2</version>  <!-- CLOCKER_VERSION -->
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>brooklyn-clocker-examples</artifactId>
    <name>Clocker Examples</name>
    <description>
        Clocker example Brooklyn blueprints for Docker.
    </description>

    <properties>
        <testLocation>jclouds:softlayer:ams01</testLocation>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.brooklyn.clocker</groupId>
            <artifactId>brooklyn-clocker-docker</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <dependency>
            <groupId>io.brooklyn.clocker</groupId>
            <artifactId>brooklyn-clocker-patches</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.brooklyn</groupId>
            <artifactId>brooklyn-jsgui</artifactId>
            <version>${brooklyn.version}</version>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>io.brooklyn.clocker</groupId>
            <artifactId>brooklyn-clocker-console</artifactId>
            <version>${project.parent.version}</version>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>org.apache.brooklyn</groupId>
            <artifactId>brooklyn-logback-xml</artifactId>
            <version>${brooklyn.version}</version>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>${testng.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.brooklyn</groupId>
            <artifactId>brooklyn-rest-client</artifactId>
            <version>${brooklyn.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.brooklyn</groupId>
            <artifactId>brooklyn-test-support</artifactId>
            <version>${brooklyn.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.brooklyn</groupId>
            <artifactId>brooklyn-core</artifactId>
            <version>${brooklyn.version}</version>
            <scope>test</scope>
            <classifier>tests</classifier>
        </dependency>
    </dependencies>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.18.1</version>
                <configuration>
                    <excludes>
                        <exclude>**/*IntegrationTest.java</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptors>
                        <descriptor>src/main/assembly/assembly.xml</descriptor>
                    </descriptors>
                    <finalName>brooklyn-clocker</finalName>
                </configuration>
                <executions>
                    <execution>
                        <id>build-distribution-archive</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <configuration>
                    <instructions>
                        <!-- OSGi specific instruction -->
                        <Import-Package>!io.airlift.command,*</Import-Package>
                    </instructions>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestFile>
                            ${project.build.outputDirectory}/META-INF/MANIFEST.MF
                        </manifestFile>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>AcceptanceTest</id>
            <activation>
                <property>
                    <name>Integration</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>1.9.1</version>
                        <executions>
                            <execution>
                                <id>reserve-brooklyn-port</id>
                                <!-- Want a port to be reserved before resources are processed. -->
                                <phase>initialize</phase>
                                <goals>
                                    <goal>reserve-network-port</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <portNames>
                                <portName>brooklyn.console</portName>
                            </portNames>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.3.2</version>
                        <executions>
                            <execution>
                                <id>run-brooklyn-server</id>
                                <phase>pre-integration-test</phase>
                                <goals><goal>exec</goal></goals>
                                <configuration>
                                    <executable>${project.build.testOutputDirectory}/run-brooklyn.sh</executable>
                                    <arguments>
                                        <argument>${project.build.directory}/brooklyn-clocker-dist/brooklyn-clocker/bin/brooklyn.sh</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- maven-resources-plugin does not preserve permissions when copying files. -->
                    <!-- https://jira.codehaus.org/browse/MRESOURCES-132 -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.8</version>
                        <executions>
                            <execution>
                                <id>fix-permissions-on-run.sh</id>
                                <phase>process-test-resources</phase>
                                <configuration>
                                    <target>
                                        <chmod file="target/test-classes/run-brooklyn.sh" perm="755"/>
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>2.18.1</version>
                        <configuration>
                            <parallel>methods</parallel>
                            <threadCount>3</threadCount>
                            <includes>
                                <include>**/*IntegrationTest.java</include>
                            </includes>
                            <systemPropertyVariables>
                                <brooklyn>http://localhost:${brooklyn.console}</brooklyn>
                            </systemPropertyVariables>
                        </configuration>
                        <executions>
                            <execution>
                                <id>integration-tests</id>
                                <goals>
                                    <goal>integration-test</goal>
                                    <goal>verify</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.brooklyn.maven</groupId>
                        <artifactId>brooklyn-maven-plugin</artifactId>
                        <version>0.2.0-SNAPSHOT</version>
                        <configuration>
                            <server>http://localhost:${brooklyn.console}</server>
                            <blueprint>${project.build.testOutputDirectory}/test-docker-cloud.yaml</blueprint>
                            <!-- Fifteen minutes for slow clouds to provision. -->
                            <timeout>15</timeout>
                        </configuration>
                        <executions>
                            <execution>
                                <id>deploy-docker-cloud</id>
                                <goals>
                                    <goal>deploy</goal>
                                    <goal>stop-brooklyn</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
