<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.jira</groupId>
    <artifactId>jira-components</artifactId>
    <version>6.4.3</version>
  </parent>
  <artifactId>atlassian-jira-webapp-platform</artifactId>
  <packaging>war</packaging>
  <name>Atlassian JIRA - Webapp - Platform</name>
  <dependencies>
      <dependency>
          <groupId>com.atlassian.jira</groupId>
          <artifactId>atlassian-jira-webapp-common</artifactId>
          <version>${project.version}</version>
          <type>war</type>
      </dependency>
  </dependencies>
  <build>
    <plugins>
       <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <executions>
          <execution>
            <id>enforce-guava</id>
            <goals>
             <goal>enforce</goal>
            </goals>
            <phase>validate</phase>
            <configuration>
              <rules>
                <bannedDependencies>
                  <searchTransitive>true</searchTransitive>
                  <message>Something is depending on google-collections (perhaps transitively), but we use guava</message>
                    <excludes>
                     <exclude>com.google.collections:google-collections</exclude>
                    </excludes>
                </bannedDependencies>
              </rules>
              <fail>true</fail>
            </configuration>
            </execution>
            <execution>
                <id>enforce-webapp-dont-exist</id>
                <goals>
                    <goal>enforce</goal>
                </goals>
                <phase>validate</phase>
                <configuration>
                    <rules>
                        <evaluateBeanshell>
                            <condition>
                                webappDir = new File("${project.basedir}" + "/src/main/webapp");
                                ( (!webappDir.exists()) || (webappDir.isDirectory() &amp;&amp; (webappDir.list().length == 0)) )
                            </condition>
                            <message>This webapp should not overlay any files. All files are intended to be placed in
                                jira-webapp-common. This webapp's sole purpose is to allow overlaying additional bundled
                                plugins. Read more: https://extranet.atlassian.com/x/ObCChg</message>
                        </evaluateBeanshell>
                    </rules>
                    <skip>${skip.webapp.empty.check}</skip>
                    <fail>true</fail>
                </configuration>
            </execution>
        </executions>
        </plugin>
    </plugins>
    <finalName>jira</finalName>
  </build>
  <profiles>
    <profile>
       <id>add-bundled-plugins</id>
       <activation>
         <property>
           <name>!jira.exclude.bundled.plugins</name>
         </property>
       </activation>
       <dependencies>
         <dependency>
           <groupId>com.atlassian.jira</groupId>
           <artifactId>jira-bundled-plugins-platform</artifactId>
           <version>${project.version}</version>
           <type>war</type>
           <scope>runtime</scope>
         </dependency>
       </dependencies>
    </profile>
    <profile>
      <id>no-skip-test-compile</id>
      <activation>
        <property>
          <name>!maven.test.skip</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.groovy.maven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <executions>
              <execution>
                <id>clean-web-inf-lib</id>
                <phase>prepare-package</phase>
                <goals>
                  <goal>execute</goal>
                </goals>
                <configuration>
                  <source>${pom.basedir}/src/main/gmaven/cleanWebInfLib.groovy</source>
                </configuration>
              </execution>
              <execution>
                <id>clean-packaging-excludes</id>
                <phase>package</phase>
                <goals>
                  <goal>execute</goal>
                </goals>
                <configuration>
                  <source>${pom.basedir}/src/main/gmaven/cleanPackagingExcludes.groovy</source>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>include-cross-selling-plugins</id>
      <activation>
        <property>
          <name>!jira.include.cross.selling.plugins.in.common</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>download-servicedesk-obr</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>copy</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>com.atlassian.servicedesk</groupId>
                      <artifactId>jira-servicedesk</artifactId>
                      <version>${bundled.servicedesk.version}</version>
                      <type>obr</type>
                      <overWrite>true</overWrite>
                      <outputDirectory>${project.build.directory}/sd-bundle</outputDirectory>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
              <execution>
                <id>copy-jira-agile-evaluation-bundle</id>
                <phase>prepare-package</phase>
                <goals>
                  <goal>copy</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>com.atlassian.jira.plugins</groupId>
                      <artifactId>jira-greenhopper-plugin</artifactId>
                      <version>${bundled.agile.version}</version>
                      <type>jar</type>
                      <overWrite>true</overWrite>
                      <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/other/jira-agile-plugin</outputDirectory>
                    </artifactItem>
                  </artifactItems>
                  <!-- other configurations here -->
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.6</version>
            <executions>
              <execution>
                <id>copy-service-desk-evaluation-bundle</id>
                <phase>prepare-package</phase>
                <configuration>
                  <tasks>
                    <echo message="unpacking servicedesk obr..." />
                    <unzip src="${project.build.directory}/sd-bundle/jira-servicedesk-${bundled.servicedesk.version}.obr" dest="${project.build.directory}/${project.build.finalName}/WEB-INF/other/service-desk-plugin">
                      <patternset>
                        <include name="**/*.jar" />
                      </patternset>
                      <flattenmapper />
                    </unzip>
                  </tasks>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
