<?xml version="1.0" encoding="UTF-8"?>
<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">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>com.atlassian.bamboo</groupId>
    <artifactId>atlassian-bamboo-plugins2-parent</artifactId>
    <version>5.11.0-m272</version>
  </parent>

  <groupId>com.atlassian.bamboo.plugins</groupId>
  <artifactId>atlassian-bamboo-plugin-test-utils</artifactId>
  <packaging>atlassian-plugin</packaging>

  <name>Atlassian Bamboo Test Utils Plugin</name>
  <description>Atlassian Bamboo Test Utils Plugin</description>

  <properties>
    <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>

    <license.scope>test</license.scope>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-test-utils</artifactId>
      <scope>compile</scope>
      <exclusions>
        <exclusion>
          <groupId>com.atlassian.selenium</groupId>
          <artifactId>atlassian-webdriver-core</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.google.code.findbugs</groupId>
          <artifactId>jsr305</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-core</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-rest-model</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-web</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo.plugins</groupId>
      <artifactId>atlassian-bamboo-plugin-git</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- Atlassian dependencies -->
    <dependency>
      <groupId>com.atlassian.annotations</groupId>
      <artifactId>atlassian-annotations</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.plugins.rest</groupId>
      <artifactId>atlassian-rest-common</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.plugins.rest</groupId>
      <artifactId>atlassian-rest-module</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.sal</groupId>
      <artifactId>sal-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.xwork</groupId>
      <artifactId>atlassian-xwork-12</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- 3rd party dependencies -->
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.inject</groupId>
      <artifactId>guice</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>dom4j</groupId>
      <artifactId>dom4j</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.acegisecurity</groupId>
      <artifactId>acegi-security</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpmime</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.jetbrains</groupId>
      <artifactId>annotations</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>jsr305</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- AMPS will automatically add org.apache.servicemix.bundles:org.apache.servicemix.bundles.junit:4.10_1:jar to bundled plugins so we can pretend that junit is provided -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-core</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-library</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.jayway.restassured</groupId>
      <artifactId>rest-assured</artifactId>
      <scope>compile</scope>
    </dependency>

    <dependency>
      <groupId>jdom</groupId>
      <artifactId>jdom</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- WIRED TEST RUNNER DEPENDENCIES -->
    <dependency>
      <groupId>com.atlassian.plugins</groupId>
      <artifactId>atlassian-plugins-osgi-testrunner</artifactId>
      <version>${plugin.testrunner.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javax.ws.rs</groupId>
      <artifactId>jsr311-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>com.atlassian.maven.plugins</groupId>
        <artifactId>maven-bamboo-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <productVersion>${atlassian.product.version}</productVersion>
          <productDataVersion>${atlassian.product.data.version}</productDataVersion>
          <containerId>${amps.containerId}</containerId>
          <instructions>
            <!-- TODO: remove the * at the end -->
            <!-- junit is marked as optional as it is required only in wired-tests so far --> 
            <Import-Package>
              com.atlassian.bamboo.*;version="0.0.0",
              com.atlassian.fugue;version="0.0.0",
              com.atlassian.plugins.rest.*;version="0.0.0",
              com.google.common.*;version="0.0.0",
              com.sun.jersey.*;version="0.0.0",
              javax.ws.rs.*;version="0.0.0",
              org.apache.commons.lang3.*;version="0.0.0",
              org.apache.commons.io.*;version="0.0.0",
              org.apache.log4j;version="0.0.0",
              org.acegisecurity.*;version="0.0.0",
              org.junit*;version="0.0.0";resolution:=optional,
              junit.framework;version="0.0.0";resolution:=optional,
              org.hamcrest*;version="0.0.0",
              *;resolution:=optional
            </Import-Package>
            <Export-Package>
              com.atlassian.bamboo.plugins.testutils*,
              com.atlassian.bamboo.testutils*
            </Export-Package>
          </instructions>

          <bundledArtifacts>
            <!-- atlassian-plugins-osgi-testrunner requires commons-io < 2.0 -->
            <bundledArtifact>
              <groupId>org.apache.servicemix.bundles</groupId>
              <artifactId>org.apache.servicemix.bundles.commons-io</artifactId>
              <version>1.4_3</version>
            </bundledArtifact>
            <bundledArtifact>
              <groupId>org.mockito</groupId>
              <artifactId>mockito-core</artifactId>
            </bundledArtifact>
            <!-- required by org.mockito:mockito-core -->
            <bundledArtifact>
              <groupId>org.objenesis</groupId>
              <artifactId>objenesis</artifactId>
            </bundledArtifact>
          </bundledArtifacts>

          <libArtifacts>
            <libArtifact>
              <groupId>junit</groupId>
              <artifactId>junit</artifactId>
            </libArtifact>
          </libArtifacts>

          <testBundleExcludes>
            <testBundleExclude>
              <groupId>com.atlassian.bamboo</groupId>
              <artifactId>atlassian-bamboo-test-utils</artifactId>
            </testBundleExclude>
          </testBundleExcludes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-jdom</id>
            <phase>compile</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>jdom</groupId>
                  <artifactId>jdom</artifactId>
                  <version>1.0</version>
                  <outputDirectory>
                    ${project.build.directory}/jdom
                  </outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <!-- Remove classes from the root package and re jar -->
            <id>fix-jdom</id>
            <phase>process-classes</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <delete>
                  <fileset dir="${project.build.directory}/jdom" includes="*.class" />
                </delete>
                <jar destfile="${project.build.directory}/jdom-1.0-fixed.jar">
                  <fileset dir="${project.build.directory}/jdom" />
                </jar>
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>

    <!-- workaround for missing feature in AMPS-4.1 -->
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
        <filtering>true</filtering>
        <includes>
          <include>atlassian-plugin.xml</include>
        </includes>
      </testResource>
      <testResource>
        <directory>src/test/resources</directory>
        <filtering>false</filtering>
        <excludes>
          <exclude>atlassian-plugin.xml</exclude>
        </excludes>
      </testResource>
    </testResources>

  </build>
</project>
