<?xml version="1.0" encoding="UTF-8"?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you 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>
    <groupId>org.apache.brooklyn</groupId>
    <artifactId>brooklyn</artifactId>
    <version>0.7.0-incubating</version>  <!-- BROOKLYN_VERSION -->
    <relativePath>../../pom.xml</relativePath>
  </parent>

  <artifactId>brooklyn-downstream-parent</artifactId>
  <packaging>pom</packaging>
  <name>Brooklyn Downstream Project Parent</name>
  <description>
      Parent pom that can be used by downstream projects that use Brooklyn,
      or that contribute additional functionality to Brooklyn.
  </description>

  <properties>
    <!-- Compilation -->
    <java.version>1.7</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <!-- Testing -->
    <testng.version>6.8.8</testng.version>
    <surefire.version>2.18.1</surefire.version>
    <includedTestGroups />
    <excludedTestGroups>Integration,Acceptance,Live,Live-sanity,WIP</excludedTestGroups>

    <!-- Dependencies -->
    <brooklyn.version>0.7.0-incubating</brooklyn.version>  <!-- BROOKLYN_VERSION -->
    <!-- versions should match those used by Brooklyn, to avoid conflicts -->
    <jclouds.version>1.9.0</jclouds.version>
    <logback.version>1.0.7</logback.version>
    <slf4j.version>1.6.6</slf4j.version>  <!-- used for java.util.logging jul-to-slf4j interception -->
    <guava.version>17.0</guava.version>
    <xstream.version>1.4.7</xstream.version>
    <jackson.version>1.9.13</jackson.version>  <!-- codehaus jackson, used by brooklyn rest server -->
    <fasterxml.jackson.version>2.4.2</fasterxml.jackson.version>  <!-- more recent jackson, but not compatible with old annotations! -->
    <jersey.version>1.18.1</jersey.version>
    <httpclient.version>4.2.5</httpclient.version>
    <commons-lang3.version>3.1</commons-lang3.version>
    <groovy.version>2.3.4</groovy.version> <!-- Version supported by https://github.com/groovy/groovy-eclipse/wiki/Groovy-Eclipse-2.9.0-Release-Notes -->
    <jsr305.version>2.0.1</jsr305.version>
    <snakeyaml.version>1.11</snakeyaml.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <!-- this would pull in all brooklyn entities and clouds;
             you can cherry pick selected ones instead (for a smaller build) -->
        <groupId>org.apache.brooklyn</groupId>
        <artifactId>brooklyn-all</artifactId>
        <version>${brooklyn.version}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <!-- this gives us flexible and easy-to-use logging; just edit logback-custom.xml! -->
      <groupId>org.apache.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;
           provided so that it isn't put into the assembly (as it supplies its own explicit logback.xml);
           see Logging in the Brooklyn website/userguide for more info -->
      <optional>true</optional>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <!-- includes testng and useful logging for tests -->
      <groupId>org.apache.brooklyn</groupId>
      <artifactId>brooklyn-test-support</artifactId>
      <version>${brooklyn.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <!-- includes brooklyn.test.LoggingVerboseReporter -->
      <groupId>org.apache.brooklyn</groupId>
      <artifactId>brooklyn-utils-test-support</artifactId>
      <version>${brooklyn.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <testSourceDirectory>src/test/java</testSourceDirectory>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
      </testResource>
    </testResources>

    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>2.5.4</version>
          <configuration>
            <tarLongFileMode>gnu</tarLongFileMode>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>2.6.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.3</version>
          <configuration>
            <source>${java.version}</source>
            <target>${java.version}</target>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-eclipse-plugin</artifactId>
          <version>2.10</version>
        </plugin>
        <plugin>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>1.4</version>
        </plugin>
        <plugin>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>2.18.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>1.6</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>2.6</version>
        </plugin>
        <plugin>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>2.10.3</version>
        </plugin>
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>2.7</version>
        </plugin>
        <plugin>
          <artifactId>maven-source-plugin</artifactId>
          <version>2.4</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.18.1</version>
        </plugin>
        <plugin>
          <groupId>org.apache.felix</groupId>
          <artifactId>maven-bundle-plugin</artifactId>
          <version>2.3.4</version>
        </plugin>
        <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <versionRange>[2.4.1,)</versionRange>
                    <goals>
                      <goal>single</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore />
                  </action>
                </pluginExecution>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <versionRange>[1.7,)</versionRange>
                    <goals>
                      <goal>attach-artifact</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore />
                  </action>
                </pluginExecution>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <versionRange>[1.3.1,)</versionRange>
                    <goals>
                      <goal>enforce</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore />
                  </action>
                </pluginExecution>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-remote-resources-plugin</artifactId>
                    <versionRange>[1.5,)</versionRange>
                    <goals>
                      <goal>process</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore />
                  </action>
                </pluginExecution>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <versionRange>[2.8,)</versionRange>
                    <goals>
                      <goal>unpack</goal>
                      <goal>copy</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore />
                  </action>
                </pluginExecution>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>com.github.skwakman.nodejs-maven-plugin</groupId>
                    <artifactId>nodejs-maven-plugin</artifactId>
                    <versionRange>[1.0.3,)</versionRange>
                    <goals>
                      <goal>extract</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore />
                  </action>
                </pluginExecution>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <versionRange>[2.4,)</versionRange>
                    <goals>
                      <goal>exploded</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore />
                  </action>
                </pluginExecution>
              </pluginExecutions>
             </lifecycleMappingMetadata>
           </configuration>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <configuration>
          <filesets>
            <fileset>
              <directory>.</directory>
              <includes>
                <include>brooklyn*.log</include>
                <include>brooklyn*.log.*</include>
                <include>stacktrace.log</include>
                <include>test-output</include>
                <include>prodDb.*</include>
              </includes>
            </fileset>
          </filesets>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
      </plugin>

      <plugin>
        <artifactId>maven-eclipse-plugin</artifactId>
        <configuration>
          <additionalProjectnatures>
            <projectnature>org.maven.ide.eclipse.maven2Nature</projectnature>
          </additionalProjectnatures>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=512m</argLine>
          <properties>
            <property>
              <name>listener</name>
              <value>brooklyn.test.LoggingVerboseReporter</value>
            </property>
          </properties>
          <enableAssertions>true</enableAssertions>
          <groups>${includedTestGroups}</groups>
          <excludedGroups>${excludedTestGroups}</excludedGroups>
          <testFailureIgnore>false</testFailureIgnore>
          <systemPropertyVariables>
            <verbose>-1</verbose>
            <net.sourceforge.cobertura.datafile>${project.build.directory}/cobertura/cobertura.ser</net.sourceforge.cobertura.datafile>
            <cobertura.user.java.nio>false</cobertura.user.java.nio>
          </systemPropertyVariables>
          <printSummary>true</printSummary>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>

    <profile>
      <id>Tests</id>
      <activation>
        <file> <exists>${basedir}/src/test</exists> </file>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-jar-plugin</artifactId>
            <inherited>true</inherited>
            <executions>
              <execution>
                <id>test-jar-creation</id>
                <goals>
                  <goal>test-jar</goal>
                </goals>
                <configuration>
                  <forceCreation>true</forceCreation>
                  <archive combine.self="override" />
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- run Integration tests with -PIntegration -->
    <profile>
      <id>Integration</id>
      <properties>
        <includedTestGroups>Integration</includedTestGroups>
        <excludedTestGroups>Acceptance,Live,Live-sanity,WIP</excludedTestGroups>
      </properties>
    </profile>

    <!-- run Live tests with -PLive -->
    <profile>
      <id>Live</id>
      <properties>
        <includedTestGroups>Live,Live-sanity</includedTestGroups>
        <excludedTestGroups>Acceptance,WIP</excludedTestGroups>
      </properties>
    </profile>

    <!-- run Live-sanity tests with -PLive-sanity -->
    <profile>
      <id>Live-sanity</id>
      <properties>
        <includedTestGroups>Live-sanity</includedTestGroups>
        <excludedTestGroups>Acceptance,WIP</excludedTestGroups>
      </properties>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-jar-plugin</artifactId>
            <executions>
              <execution>
                <id>test-jar-creation</id>
                <configuration>
                  <skip>true</skip>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>Bundle</id>
      <activation>
        <file>
          <!-- NB - this is all the leaf projects, including logback-* (with no src);
               the archetype project neatly ignores this however -->
          <exists>${basedir}/src</exists>
        </file>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <!-- configure plugin to generate MANIFEST.MF
                 adapted from http://blog.knowhowlab.org/2010/06/osgi-tutorial-from-project-structure-to.html -->
            <executions>
              <execution>
                <id>bundle-manifest</id>
                <phase>process-classes</phase>
                <goals>
                  <goal>manifest</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <supportedProjectTypes>
                <supportedProjectType>jar</supportedProjectType>
              </supportedProjectTypes>
              <instructions>
                <!-- OSGi specific instruction -->
                <!--
                    By default packages containing impl and internal
                    are not included in the export list. Setting an
                    explicit wildcard will include all packages
                    regardless of name.
                    In time we should minimize our export lists to
                    what is really needed.
                -->
                <Export-Package>brooklyn.*</Export-Package>
                <!-- Brooklyn-Feature prefix triggers inclusion of the project's metadata in the server's features list. -->
                <Brooklyn-Feature-Name>${project.name}</Brooklyn-Feature-Name>
              </instructions>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
              <archive>
                <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
              </archive>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- different properties used to deploy to different locations depending on profiles;
         default is cloudsoft filesystem repo, but some sources still use cloudsoft artifactory as source
         and soon we will support artifactory. use this profile for the ASF repositories and
         sonatype-oss-release profile for the Sonatype OSS repositories.
    -->
    <!-- profile>
      <id>apache-release</id>
      <activation>
        <property>
          <name>brooklyn.deployTo</name>
          <value>apache</value>
        </property>
      </activation>
      <distributionManagement>
        <repository>
          <id>apache.releases.https</id>
          <name>Apache Release Distribution Repository</name>
          <url>https://repository.apache.org/service/local/staging/deploy/maven2</url>
        </repository>
        <snapshotRepository>
          <id>apache.snapshots.https</id>
          <name>Apache Development Snapshot Repository</name>
          <url>https://repository.apache.org/content/repositories/snapshots</url>
        </snapshotRepository>
      </distributionManagement>
    </profile -->
  </profiles>

</project>
