<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.bamboo</groupId>
    <artifactId>atlassian-bamboo-components</artifactId>
    <version>4.1-m3</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>atlassian-bamboo-agent-elastic-s3-bucket</artifactId>
  <name>Atlassian Bamboo Elastic Agent Assembly</name>
  <packaging>aws</packaging>

  <properties>
    <agentAssemblyDirectoryParent>${project.build.directory}/assembly/contents</agentAssemblyDirectoryParent>
  </properties>

  <!-- When modifying dependencies of this module ensure that you update the asssembly.xml for excludes and includes -->
  <dependencies>

    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-api</artifactId>
    </dependency>
    
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-core</artifactId>
    </dependency>

    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-agent-remote</artifactId>
    </dependency>

    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-agent-elastic-s3-bucket-boot</artifactId>
      <type>zip</type>
    </dependency>

    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-elastic-image</artifactId>
      <type>ami</type>
    </dependency>

    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-plugins1-plugins</artifactId>
      <type>pom</type>
      <exclusions>
        <exclusion>
          <groupId>com.atlassian.bamboo</groupId>
          <artifactId>atlassian-bamboo-upgrade</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

		<dependency>
			<groupId>com.atlassian.bamboo</groupId>
			<artifactId>atlassian-bamboo-bundled-plugins</artifactId>
			<type>zip</type>
		</dependency>

    <dependency>
      <groupId>com.atlassian.aws</groupId>
      <artifactId>atlassian-aws</artifactId>
    </dependency>

    <dependency>
      <groupId>commons-httpclient</groupId>
      <artifactId>commons-httpclient</artifactId>
      <version>3.0.1</version>
		</dependency>

    <dependency>
      <groupId>com.cenqua.clover</groupId>
      <artifactId>clover</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-embedder</artifactId>
    </dependency>

    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>

    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
    </dependency>

    <dependency>
        <groupId>opensymphony</groupId>
        <artifactId>xwork</artifactId>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <scope>runtime</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-boot-classpath</id>
            <goals>
              <goal>unpack</goal>
            </goals>
            <phase>compile</phase>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.atlassian.bamboo</groupId>
                  <artifactId>atlassian-bamboo-agent-elastic-s3-bucket-boot</artifactId>
                  <type>zip</type>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.directory}</outputDirectory>
                </artifactItem>
                <artifactItem>
                  <groupId>com.atlassian.bamboo</groupId>
                  <artifactId>atlassian-bamboo-bundled-plugins</artifactId>
                  <type>zip</type>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.directory}/bundled-plugins</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>

          <execution>
            <id>get-amis</id>
            <goals>
              <goal>copy</goal>
            </goals>
            <phase>compile</phase>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.atlassian.bamboo</groupId>
                  <artifactId>atlassian-bamboo-elastic-image</artifactId>
                  <type>ami</type>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.directory}</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>

        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.2-beta-4</version>
        <executions>
          <execution>
            <id>build-s3-assembly</id>
            <goals>
              <goal>single</goal>
            </goals>
            <phase>compile</phase>
            <configuration>
              <finalName>contents</finalName>
              <descriptors>
                <descriptor>src/main/assembly/assembly.xml</descriptor>
              </descriptors>
              <appendAssemblyId>false</appendAssemblyId>
              <outputDirectory>${project.build.directory}/assembly</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.atlassian.maven.plugins</groupId>
        <artifactId>maven-aws-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <imageListFile>${project.build.directory}/atlassian-bamboo-elastic-image-${elastic-image.version}.ami</imageListFile>
          <awsSecretAccessKey>${aws.secretAccessKey}</awsSecretAccessKey>
          <awsAccessKeyID>${aws.accessKeyID}</awsAccessKeyID>
          <agentAssemblyDirectoryName>${agentAssemblyDirectoryParent}</agentAssemblyDirectoryName>
          <regionalisedBuckets>
             <regionalisedBucket>${s3.imageBucketStem}</regionalisedBucket>
             <regionalisedBucket>${s3.agentAssemblyBucketStem}</regionalisedBucket>
          </regionalisedBuckets>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
