<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>9.0.0-m023</version>
  </parent>

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

  <name>Atlassian Bamboo REST plugin</name>
  <description>REST API for Bamboo</description>

  <properties>
    <atlassian.plugin.key>com.atlassian.bamboo.plugins.rest</atlassian.plugin.key>
    <jersey.release.version>1.19.4</jersey.release.version>
    <!-- a version of maven-wadl-plugin patched to fix https://java.net/jira/browse/JERSEY-2709 -->
    <jersey.wadl.plugin.version>1.19-atlassian-7</jersey.wadl.plugin.version>
  </properties>

  <dependencies>

    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-web</artifactId>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <!--
            prevent occurrence of https://www.slf4j.org/faq.html#IllegalAccessError while running AMPS' generate-rest-docs.
            AMPS uses hardcoded atlassian-rest-doclet:2.9.2, which depends on slf4j-api:1.5.8
            -->
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-log4j12</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-rest-model</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-rest-common</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-charts</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-deployments-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-deployments</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-import-export</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-utils</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- other Atlassian dependencies -->
    <dependency>
      <groupId>com.atlassian.annotations</groupId>
      <artifactId>atlassian-annotations</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.plugins</groupId>
      <artifactId>atlassian-plugins-core</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.plugin</groupId>
      <artifactId>atlassian-spring-scanner-annotation</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.sal</groupId>
      <artifactId>sal-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.user</groupId>
      <artifactId>atlassian-user-core</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- 3rd party dependencies -->
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.atlassian.fugue</groupId>
      <artifactId>fugue</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.atlassian.util.concurrent</groupId>
      <artifactId>atlassian-util-concurrent</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jaxb</groupId>
      <artifactId>jaxb-runtime</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-lang3</artifactId>
       <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.quartz-scheduler</groupId>
      <artifactId>quartz</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.reflections</groupId>
      <artifactId>reflections</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- test dependencies -->
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-pageobjects</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-test-utils</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.selenium</groupId>
      <artifactId>atlassian-pageobjects-elements</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.rest-assured</groupId>
      <artifactId>rest-assured</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>pl.pragmatists</groupId>
      <artifactId>JUnitParams</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-core-asl</artifactId>
      <scope>compile</scope>
    </dependency>

  </dependencies>

  <profiles>
    <profile>
      <id>restdoc</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <executions>
              <execution>
                <phase>pre-site</phase>
                <goals>
                  <goal>compile</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <id>02-schemaGen-plugin-description</id>
                <phase>pre-site</phase>
                <goals>
                  <goal>javadoc</goal>
                </goals>
                <configuration>
                  <verbose>false</verbose>
                  <show>public</show>
                  <subpackages>com</subpackages>
                  <doclet>com.sun.jersey.wadl.resourcedoc.ResourceDoclet</doclet>
                  <docletArtifacts>
                    <docletArtifact>
                      <groupId>com.sun.jersey.contribs</groupId>
                      <artifactId>wadl-resourcedoc-doclet</artifactId>
                      <version>${jersey.release.version}</version>
                    </docletArtifact>
                    <docletArtifact>
                      <groupId>com.sun.jersey.samples</groupId>
                      <artifactId>generate-wadl</artifactId>
                      <version>${jersey.release.version}</version>
                    </docletArtifact>
                    <docletArtifact>
                      <groupId>xerces</groupId>
                      <artifactId>xercesImpl</artifactId>
                      <version>${xerces.version}</version>
                    </docletArtifact>
                    <docletArtifact>
                      <groupId>javax.xml.bind</groupId>
                      <artifactId>jaxb-api</artifactId>
                      <version>${jaxb.version}</version>
                    </docletArtifact>
                    <docletArtifact>
                      <groupId>org.glassfish.jaxb</groupId>
                      <artifactId>jaxb-runtime</artifactId>
                      <version>${jaxb.version}</version>
                    </docletArtifact>
                  </docletArtifacts>
                  <additionalDependencies>
                    <!-- needed to have all classes present on classpath, including classes containing example documents -->
                    <additionalDependency>
                      <groupId>${project.groupId}</groupId>
                      <artifactId>${project.artifactId}</artifactId>
                      <version>${project.version}</version>
                    </additionalDependency>
                  </additionalDependencies>
                  <additionalparam>-output ${project.build.outputDirectory}/resourcedoc.xml -processors com.sun.jersey.samples.generatewadl.util.ExampleDocProcessor</additionalparam>
                  <useStandardDocletOptions>false</useStandardDocletOptions>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>maven-wadl-plugin</artifactId>
            <version>${jersey.wadl.plugin.version}</version>
            <dependencies>
              <dependency>
                <groupId>xerces</groupId>
                <artifactId>xercesImpl</artifactId>
                <version>${xerces.version}</version>
              </dependency>
              <dependency>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>${jaxb.version}</version>
              </dependency>
              <dependency>
                <groupId>org.glassfish.jaxb</groupId>
                <artifactId>jaxb-runtime</artifactId>
                <version>${jaxb.version}</version>
              </dependency>
            </dependencies>
            <executions>
              <execution>
                <id>03-generate</id>
                <goals>
                  <goal>generate</goal>
                </goals>
                <phase>pre-site</phase>
              </execution>
            </executions>
            <configuration>
              <wadlFile>${project.build.outputDirectory}/application.wadl</wadlFile>
              <formatWadlFile>true</formatWadlFile>
              <baseUri>http://myhost.com:8085/rest/api/latest/</baseUri>
              <packagesResourceConfig>
                <param>com.atlassian.bamboo.plugins.rest.build</param>
                <param>com.atlassian.bamboo.plugins.rest.deployments</param>
                <param>com.atlassian.bamboo.plugins.rest.permission</param>
                <param>com.atlassian.bamboo.plugins.rest.resource</param>
                <param>com.atlassian.bamboo.plugins.rest.user</param>
                <param>com.atlassian.bamboo.plugins.rest.encrypt</param>
              </packagesResourceConfig>
              <wadlGenerators>
                <wadlGeneratorDescription>
                  <className>com.sun.jersey.server.wadl.generators.WadlGeneratorApplicationDoc</className>
                  <properties>
                    <property>
                      <name>applicationDocsFile</name>
                      <value>${basedir}/src/main/doc/application-doc.xml</value>
                    </property>
                  </properties>
                </wadlGeneratorDescription>
                <wadlGeneratorDescription>
                  <className>com.sun.jersey.server.wadl.generators.WadlGeneratorGrammarsSupport</className>
                  <properties>
                    <property>
                      <name>grammarsFile</name>
                      <value>${basedir}/src/main/doc/application-grammars.xml</value>
                    </property>
                  </properties>
                </wadlGeneratorDescription>
                <wadlGeneratorDescription>
                  <className>com.sun.jersey.server.wadl.generators.resourcedoc.WadlGeneratorResourceDocSupport</className>
                  <properties>
                    <property>
                      <name>resourceDocFile</name>
                      <value>${project.build.outputDirectory}/resourcedoc.xml</value>
                    </property>
                  </properties>
                </wadlGeneratorDescription>
              </wadlGenerators>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>xml-maven-plugin</artifactId>
            <version>1.0.2</version>
            <executions>
              <execution>
                <id>04-xsl transform target/application.html</id>
                <goals>
                  <goal>transform</goal>
                </goals>
                <phase>site</phase>
                <configuration>
                  <transformationSets>
                    <transformationSet>
                      <dir>target/classes</dir>
                      <includes>
                        <include>application.wadl</include>
                      </includes>
                      <stylesheet>src/main/doc/wadl-documentation.xsl</stylesheet>
                    </transformationSet>
                  </transformationSets>
                  <!-- the XSL above requires EXSLT node-set support, which xalan doesn't provide? -->
                  <transformerFactory>net.sf.saxon.TransformerFactoryImpl</transformerFactory>
                </configuration>
              </execution>
            </executions>
            <dependencies>
              <dependency>
                <groupId>net.sf.saxon</groupId>
                <artifactId>saxon</artifactId>
                <version>8.7</version>
              </dependency>
            </dependencies>
          </plugin>

          <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <id>05-prepare-docs</id>
                <phase>site</phase>
                <goals>
                  <goal>run</goal>
                </goals>
                <configuration>
                  <target>
                    <mkdir dir="target/restdocs" />
                    <copy file="target/generated-resources/xml/xslt/application.wadl" toFile="target/restdocs/index.html" />
                    <copy file="target/classes/xsd0.xsd" toFile="target/restdocs/xsd0.xsd" />
                  </target>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      <dependencies>
        <!-- override the scope in this profile because javadoc needs them at compile -->
        <dependency>
          <groupId>com.atlassian.bamboo</groupId>
          <artifactId>atlassian-bamboo-core</artifactId>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>com.atlassian.plugins.rest</groupId>
          <artifactId>atlassian-rest-common</artifactId>
          <scope>compile</scope>
        </dependency>
      </dependencies>
    </profile>
    <profile>
      <id>release-profile</id>
      <properties>
        <skipTests>true</skipTests>
      </properties>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <skip>true</skip>
              <skipTests>true</skipTests>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <reporting>
    <plugins>
      <plugin>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
          <maxmemory>1024m</maxmemory>
        </configuration>
        <reportSets>
          <reportSet>
            <id>default</id>
            <reports>
              <report>aggregate</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-project-info-reports-plugin</artifactId>
      </plugin>
    </plugins>
  </reporting>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-site-plugin</artifactId>
          <configuration>
            <inputDirectory>${project.reporting.outputDirectory}/apidocs</inputDirectory>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>com.atlassian.plugin</groupId>
        <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>com.atlassian.maven.plugins</groupId>
        <artifactId>bamboo-maven-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
            <Spring-Context>*;timeout:=60</Spring-Context>
            <Export-Package>
              com.atlassian.bamboo.plugins.rest.common.*,
              com.atlassian.bamboo.rest.common.*,
              com.atlassian.bamboo.rest.model.*
            </Export-Package>
            <Import-Package>
              <!-- General Resolution -->
              com.atlassian.analytics.api.annotations;version="0.0.0",
              com.atlassian.analytics.api.services;version="0.0.0",
              com.atlassian.applinks.api;version="0.0.0",
              com.atlassian.aws;version="0.0.0",
              com.atlassian.aws.ec2*;version="0.0.0",
              com.atlassian.bamboo.*;version="0.0.0",
              com.atlassian.core.i18n;version="0.0.0",
              com.atlassian.crowd.integration;version="0.0.0",
              com.atlassian.event.api;version="0.0.0",
              com.atlassian.fugue;version="0.0.0",
              io.atlassian.fugue;version="0.0.0",
              com.atlassian.http.mime,
              com.atlassian.plugin;version="0.0.0",
              com.atlassian.plugins.rest.common*;version="0.0.0",
              com.atlassian.sal.api;version="0.0.0",
              com.atlassian.sal.api.net;version="0.0.0",
              com.atlassian.security.password;version="0.0.0",
              com.atlassian.spring.container;version="0.0.0",
              com.atlassian.struts;version="0.0.0",
              com.atlassian.user;version="0.0.0",
              com.atlassian.user.search*;version="0.0.0",
              com.amazonaws.services.ec2.model;version="0.0.0",
              com.google.common.*;version="0.0.0",
              com.google.gson;version="0.0.0",
              com.opensymphony.module.propertyset;version="0.0.0",
              com.sun.jersey.*;version="0.0.0",
              io.atlassian.util.concurrent;version="0.0.0",
              javax.annotation;version="0.0.0",
              javax.servlet;version="0.0.0",
              javax.servlet.http;version="0.0.0",
              javax.ws.rs;version="0.0.0",
              javax.ws.rs.*;version="0.0.0",
              javax.xml.bind.annotation*;version="0.0.0",
              org.acegisecurity;version="0.0.0",
              org.acegisecurity.acls;version="0.0.0",
              org.apache.commons.*;version="0.0.0",
              org.codehaus.jackson.*;version="0.0.0",
              org.apache.log4j;version="0.0.0",
              org.jfree.data.*;version="0.0.0",
              org.joda.time;version="0.0.0",
              org.joda.time.format;version="0.0.0",
              org.quartz;version="0.0.0",
              *;resolution:=optional
            </Import-Package>
          </instructions>
          <products>
            <product>
              <id>bamboo</id>
              <instanceId>bamboo</instanceId>
              <systemPropertyVariables>
                <atlassian.darkfeature.bamboo.experimental.rest.admin.enabled>true</atlassian.darkfeature.bamboo.experimental.rest.admin.enabled>
                <atlassian.darkfeature.bamboo.sox.compliance.configurable>true</atlassian.darkfeature.bamboo.sox.compliance.configurable>
                <atlassian.darkfeature.bamboo.improved.admin.panel.nav>true</atlassian.darkfeature.bamboo.improved.admin.panel.nav>
                <bamboo.allow.url.parameters.login>true</bamboo.allow.url.parameters.login>
              </systemPropertyVariables>
            </product>
            <product>
              <id>bamboo</id>
              <instanceId>bamboo-rest-admin-off</instanceId>
            </product>
          </products>
          <pluginArtifacts>
            <pluginArtifact>
              <groupId>com.atlassian.bamboo.plugins</groupId>
              <artifactId>atlassian-bamboo-plugin-test-utils</artifactId>
            </pluginArtifact>
          </pluginArtifacts>
          <testGroups>
            <testGroup>
              <id>bamboo</id>
              <instanceIds>
                <instanceId>bamboo</instanceId>
              </instanceIds>
              <includes>
                <include>it/**/*Test.java</include>
              </includes>
              <excludes>
                <exclude>it/com/atlassian/bamboo/plugins/rest/admin/filters/*Test.java</exclude>
              </excludes>
            </testGroup>
            <testGroup>
              <id>bamboo-darkfeature-tests</id>
              <instanceIds>
                <instanceId>bamboo-rest-admin-off</instanceId>
              </instanceIds>
              <includes>
                <include>it/com/atlassian/bamboo/plugins/rest/admin/filters/*Test.java</include>
              </includes>
            </testGroup>
          </testGroups>
        </configuration>
      </plugin>
    </plugins>
  </build>

</project>
