<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>5.9-m08</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <artifactId>atlassian-bamboo-web-app</artifactId>
  <version>5.9-m08</version>

  <packaging>war</packaging>

  <name>Atlassian Bamboo Web Application</name>

  <properties>
    <pluginBundleDirectory>target/bundled-plugins</pluginBundleDirectory>
    <source.setup.aui.target.directory>${project.basedir}/src/main/webapp/layout/setup</source.setup.aui.target.directory>
  </properties>

  <dependencies>

    <dependency>
      <groupId>com.atlassian.sal</groupId>
      <artifactId>sal-api</artifactId>
    </dependency>

    <dependency>
      <groupId>com.atlassian.applinks</groupId>
      <artifactId>applinks-api</artifactId>
    </dependency>

    <dependency>
      <groupId>com.atlassian.applinks</groupId>
      <artifactId>applinks-host</artifactId>
    </dependency>

    <dependency>
      <groupId>com.atlassian.applinks</groupId>
      <artifactId>applinks-spi</artifactId>
    </dependency>

    <!-- Module dependencies -->
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-web</artifactId>
    </dependency>

    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-deployments</artifactId>
    </dependency>

    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-test-utils</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-plugins1-plugins</artifactId>
      <type>pom</type>
      <version>${project.version}</version>
    </dependency>

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

    <!-- Ensure that bundled modules aren't added twice but is still built before -->
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-bundled-plugins</artifactId>
      <type>zip</type>
      <scope>provided</scope>
    </dependency>

    <!-- Ensure that atlassian-bamboo-agent-installer isn't added twice but is still built before -->
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>atlassian-bamboo-agent-installer</artifactId>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>com.atlassian.bamboo</groupId>
          <artifactId>bamboo-agent-bootstrap</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- Ensure that bamboo-agent isn't added twice but is still built before -->
    <dependency>
      <groupId>com.atlassian.bamboo</groupId>
      <artifactId>bamboo-agent</artifactId>
      <scope>provided</scope>
    </dependency>

    <!--Currently required on the class path, by crowd + other plugins that use REST-->
    <dependency>
      <groupId>com.sun.xml.bind</groupId>
      <artifactId>jaxb-impl</artifactId>
    </dependency>

    <!--another hack for weird mvn bug - testtools with test scope excludes this-->
    <dependency>
      <groupId>dom4j</groupId>
      <artifactId>dom4j</artifactId>
    </dependency>

    <!-- we want to bundle hamcrest-all to avoid OSGi issues -->
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-core</artifactId>
      <scope>provided</scope>
    </dependency>

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

    <dependency>
      <groupId>com.atlassian.security.auth.trustedapps</groupId>
      <artifactId>atlassian-trusted-apps-core</artifactId>
    </dependency>

    <dependency>
      <groupId>com.atlassian.plugins</groupId>
      <artifactId>atlassian-plugins-webresource</artifactId>
      <scope>runtime</scope>
    </dependency>

    <!-- PostgreSQL JDBC driver -->
    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- MS SQL JDBC Driver -->
    <dependency>
      <groupId>net.sourceforge.jtds</groupId>
      <artifactId>jtds</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- MySQL JDBC Driver -->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Oracle JDBC Driver -->
    <dependency>
      <groupId>com.oracle</groupId>
      <artifactId>ojdbc6</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- JDBC logger -->
    <dependency>
      <groupId>org.bgee.log4jdbc-log4j2</groupId>
      <artifactId>log4jdbc-log4j2-jdbc4</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
    </dependency>

  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <overlays>
            <overlay>
              <groupId>com.atlassian.bamboo</groupId>
              <artifactId>atlassian-bamboo-bundled-plugins</artifactId>
              <type>zip</type>
              <targetPath>WEB-INF/atlassian-bundled-plugins</targetPath>
            </overlay>
          </overlays>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
            </manifest>
          </archive>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <!-- can't get Hibernate tests running in parallel in the same process -->
          <parallel>none</parallel>
          <forkCount>1C</forkCount>
          <reuseForks>false</reuseForks>
        </configuration>
      </plugin>

      <!-- Plugin for packaging the agent jars-->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <phase>process-resources</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.atlassian.bamboo</groupId>
                  <artifactId>atlassian-bamboo-agent-installer</artifactId>
                  <outputDirectory>${project.build.directory}/${project.artifactId}/admin/agent</outputDirectory>
                </artifactItem>
                <artifactItem>
                  <groupId>com.atlassian.bamboo</groupId>
                  <artifactId>bamboo-agent</artifactId>
                  <outputDirectory>${project.build.directory}/${project.artifactId}/admin/agent</outputDirectory>
                </artifactItem>
                <artifactItem>
                  <groupId>com.atlassian.bamboo</groupId>
                  <artifactId>atlassian-bamboo-agent-installer</artifactId>
                  <type>jar</type>
                  <outputDirectory>${project.build.directory}/classes</outputDirectory>
                  <destFileName>agent-installer.jar</destFileName>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
          <!-- unpack AUI sources for setup (we're unpacking to source directory so IDEA can pick them when running Bamboo from IDE -->
          <execution>
            <id>unpack-aui-flatpack</id>
            <phase>process-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <!-- if output path of this artifact changes do not forget to update maven-clean-plugin configuration below -->
                <artifactItem>
                  <groupId>com.atlassian.aui</groupId>
                  <artifactId>aui-flat-pack</artifactId>
                  <type>zip</type>
                  <outputDirectory>${source.setup.aui.target.directory}</outputDirectory>
                  <includes>aui/aui/css/**,aui/aui/js/**</includes>
                  <overWrite>true</overWrite>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
          <execution>
            <id>include-aws</id>
            <phase>process-resources</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <includeTypes>aws</includeTypes>
              <outputDirectory>${project.build.outputDirectory}</outputDirectory>
              <stripVersion>true</stripVersion>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <configuration>
          <filesets>
            <fileset>
              <directory>${source.setup.aui.target.directory}/aui</directory>
            </fileset>
          </filesets>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>com.atlassian.lesscss</groupId>
        <artifactId>lesscss-maven-plugin</artifactId>
        <version>${atlassian.less.transformer.version}</version>
        <configuration>
          <outputDirectory>${project.basedir}/src/main/webapp</outputDirectory>
          <resourcePlugins>
            <bamboo.web.resources.common>../../../../bamboo-plugins2/bamboo-plugin-web-resources/src/main/resources</bamboo.web.resources.common>
          </resourcePlugins>
          <!-- IDEA uses stuff from /src-->
        </configuration>
        <executions>
          <execution>
            <id>compile-less</id>
            <phase>process-resources</phase>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-enforcer-plugin</artifactId>
        <executions>
          <execution>
            <id>enforce-banned-dependencies</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <bannedDependencies>
                  <searchTransitive>false</searchTransitive>
                  <excludes>
                    <exclude>javax.servlet</exclude>
                    <exclude>javax.servlet.jsp</exclude>
                  </excludes>
                  <includes>
                    <include>javax.servlet:*:*:provided</include>
                    <include>javax.servlet.jsp:*:*:provided</include>
                  </includes>
                  <message>See Servlet Spec 2.3, section 9.7.2.</message>
                </bannedDependencies>
              </rules>
              <fail>true</fail>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- for ftl-s to be copied to test-classes and be seen in tests -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-test-resource</id>
            <phase>generate-test-resources</phase>
            <goals>
              <goal>add-test-resource</goal>
            </goals>
            <configuration>
              <resources>
                <resource>
                  <directory>src/main/webapp</directory>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <!-- this profile needs a BOM. Generate it previously with 'verify license:bom'. 
         And don't add license:bom as part of your lifecycle. 
         https://extranet.atlassian.com/x/SJbzew -->
    <profile>
      <id>third-party-licensing</id>
      <build>
          <plugins>
            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>build-helper-maven-plugin</artifactId>
              <executions>
                <execution>
                  <id>attach-artifacts</id>
                  <phase>package</phase>
                  <goals>
                    <goal>attach-artifact</goal>
                  </goals>
                  <configuration>
                    <artifacts>
                      <artifact>
                        <file>${thirdpartylicensing.bom}</file>
                        <type>csv</type>
                        <classifier>bom</classifier>
                      </artifact>
                    </artifacts>
                  </configuration>
                </execution>
              </executions>
            </plugin>
            <plugin>
              <groupId>com.atlassian.maven.plugins</groupId>
              <artifactId>maven-licensing-bom-processor-plugin</artifactId>
              <version>0.3</version>
              <executions>
                <execution>
                  <id>process-licences</id>
                  <phase>generate-resources</phase>
                  <goals>
                    <goal>generate</goal>
                  </goals>
                  <configuration>
                    <bom>${project.basedir}/../../third-party-licensing/bom.csv</bom>
                    <template>${project.basedir}/src/main/resources/static/lgplTemplate.soy</template>
                    <templateName>bamboo.build.generate.licenseTemplates</templateName>
                    <output>${project.build.directory}/${project.artifactId}/about/lgpl.soy</output>
                  </configuration>
                </execution>
              </executions>
            </plugin>
          </plugins>
        </build>
    </profile>
  </profiles>
</project>
