<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>
    <groupId>com.atlassian.pom</groupId>
    <artifactId>atlassian-plugin-pom</artifactId>
    <packaging>pom</packaging>
    <version>9</version>
    <name>Atlassian Plugin POM</name>

    <parent>
        <artifactId>atlassian-contrib-pom</artifactId>
        <groupId>com.atlassian.pom</groupId>
        <version>12</version>
    </parent>

    <scm>
        <connection>scm:svn:https://svn.atlassian.com/svn/public/atlassian/pom/atlassian-plugin-pom/tags/atlassian-plugin-pom-9</connection>
        <developerConnection>scm:svn:https://svn.atlassian.com/svn/public/atlassian/pom/atlassian-plugin-pom/tags/atlassian-plugin-pom-9</developerConnection>
        <url>https://svn.atlassian.com/svn/public/atlassian/pom/atlassian-plugin-pom/tags/atlassian-plugin-pom-9</url>
    </scm>

    <developers>
        <developer>
            <name>Atlassian Developers</name>
            <organization>Atlassian</organization>
        </developer>
    </developers>

    <properties>
        <maven.test.it.skip>${maven.test.skip}</maven.test.it.skip>
        <maven.test.unit.skip>${maven.test.skip}</maven.test.unit.skip>

        <tomcat.installer.url>
           https://m2proxy.atlassian.com/repository/public/org/apache/tomcat/apache-tomcat/5.5.23/apache-tomcat-5.5.23-jdk14.zip 
        </tomcat.installer.url>
        <!-- The path we want to deploy webapps to -->
        <base.webapp.directory>${project.build.directory}</base.webapp.directory>

        <cargo.wait />
        <confluence.wait>false</confluence.wait>
        <jira.wait>false</jira.wait>
        
        <!-- One of jvmargs.debug.* will be appended to <jvmargs> depending on the context. -->
        <jvmargs.debug.confluence />
        <jvmargs.debug.jira />
        <jvmargs.debug.fisheye />
        <jvmargs.debug.bamboo />
        <!--
            We need a larger permanent generation size because Confluence 2.10 is using more than the default.
            If this needs to be changed, it must be moved, not removed.
        -->
        <jvmargs>-XX:MaxPermSize=256m -Xms128m -Xmx564m</jvmargs>

        <!-- Version of test harness to deploy web apps with -->
        <atlassian.test.harness.version>0.8</atlassian.test.harness.version>

        <!-- Default Clover license location -->
        <clover.licenseLocation>${user.home}/.m2/clover.license</clover.licenseLocation>

        <!-- Do we want to install the project artifact as a Confluence plugin? -->
        <confluence.plugin.install>false</confluence.plugin.install>
        <!-- Is the project artifact a Confluence bundled plugin? -->
        <confluence.plugin.bundled>false</confluence.plugin.bundled>
        <!-- Path to the text file containing regexes of jars to remove, one on each line. -->
        <confluence.jars.to.remove.regex.list />
        <confluence.version>2.9</confluence.version>
        <confluence.data.version>2.9</confluence.data.version>
        <confluence.test-lib.version>1.4.1</confluence.test-lib.version>
        <confluence.http.port>8080</confluence.http.port>
        <confluence.rmi.port>9899</confluence.rmi.port>
        <confluence.context.path>confluence</confluence.context.path>
        <!-- Do we want to start the Confluence application? -->
        <confluence.start>false</confluence.start>

        <!-- Do we want to install the project artifact as a JIRA plugin? -->
        <jira.plugin.install>false</jira.plugin.install>
        <!-- Path to the text file containing regexes of jars to remove from WEB-INF/lib, one on each line. -->
        <jira.jars.to.remove.regex.list />
        <jira.version>3.12.2</jira.version>
        <jira.data.version>3.11</jira.data.version>
        <jira.test-lib.version>3.12.2</jira.test-lib.version>
        <jira.http.port>8081</jira.http.port>
        <jira.rmi.port>9900</jira.rmi.port>
        <jira.context.path>jira</jira.context.path>
        <!-- Do we want to start the JIRA application? -->
        <jira.start>false</jira.start>

        <!-- We do not want to install this artifact as a FishEye plugin (StartFisheyeMojo in the Atlassian Test Harness)
             does not support it. Still, I made this dynamic just in case the mojo allows it in the future.
        -->
        <fisheye.plugin.install>false</fisheye.plugin.install>
        <!-- Like the above, this setting has no effect for now. However, that might change in the future. -->
        <fisheye.jars.to.remove.regex.list />
        <fisheye.version>1.2.0</fisheye.version>
        <fisheye.http.port>8082</fisheye.http.port>
        <fisheye.rmi.port>9901</fisheye.rmi.port>
        <fisheye.context.path>fisheye</fisheye.context.path>
        <!-- Do we want to start the FishEye application? -->
        <fisheye.start>false</fisheye.start>

        <!-- Do we want to install the project artifact as a Bamboo plugin? -->
        <bamboo.plugin.install>false</bamboo.plugin.install>
        <!-- Path to the text file containing regexes of jars to remove from WEB-INF/lib, one on each line. -->
        <bamboo.jars.to.remove.regex.list />
        <bamboo.version>2.0</bamboo.version>
        <bamboo.data.version>2.0</bamboo.data.version>
        <bamboo.http.port>8083</bamboo.http.port>
        <bamboo.rmi.port>9902</bamboo.rmi.port>
        <bamboo.context.path>bamboo</bamboo.context.path>
        <!-- Do we want to start the Bamboo application? -->
        <bamboo.start>false</bamboo.start>

    </properties>

    <profiles>
        <profile>
            <id>plugin-debug</id>
            <build>
                <defaultGoal>verify</defaultGoal>
            </build>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <maven.test.skip>true</maven.test.skip>
                <base.webapp.directory>${basedir}/debug</base.webapp.directory>
                <cargo.wait>true</cargo.wait>

                <jvmargs.debug.confluence>-Xdebug -Xnoagent
                    -Xrunjdwp:server=y,transport=dt_socket,address=5005,suspend=n
                </jvmargs.debug.confluence>

                <jvmargs.debug.jira>-Xdebug -Xnoagent -Xrunjdwp:server=y,transport=dt_socket,address=5006,suspend=n
                </jvmargs.debug.jira>

                <jvmargs.debug.fisheye>-Xdebug -Xnoagent -Xrunjdwp:server=y,transport=dt_socket,address=5007,suspend=n
                </jvmargs.debug.fisheye>

                <jvmargs.debug.bamboo>-Xdebug -Xnoagent -Xrunjdwp:server=y,transport=dt_socket,address=5008,suspend=n
                </jvmargs.debug.bamboo>
            </properties>
        </profile>
    </profiles>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>atlassian-plugin.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>atlassian-plugin.xml</exclude>
                </excludes>
            </resource>
        </resources>

        <plugins>
            <!-- enables atlassian-plugin packaging type -->
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>atlassian-pdk</artifactId>
                <extensions>true</extensions>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.1</version>
                    <executions>
                        <execution>
                            <id>generate-integration-test-config</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                        </execution>
                        <!-- Allows users to define arbitrary Ant tasks to be executed before integration tests (and after generate-integration-test-config) -->
                        <execution>
                            <id>pre-integration-test-user-ant-tasks</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                        </execution>
                        <!-- Allows users to define arbitrary Ant tasks to be executed after integration tests -->
                        <execution>
                            <id>post-integration-test-user-ant-tasks</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <groupId>com.atlassian.maven.plugins.testharness</groupId>
                    <artifactId>atlassian-test-harness</artifactId>
                    <version>${atlassian.test.harness.version}</version>

                    <executions>
                        <!-- FishEye has to be at the top because it doesn't support <wait>. -->
                        <execution>
                            <id>start-fisheye</id>
                            <goals>
                                <goal>start-fisheye</goal>
                            </goals>
                            <phase>pre-integration-test</phase>
                            <configuration>
                                <svnUrl>${base.webapp.directory}/fisheye</svnUrl>
                                <version>${fisheye.version}</version>
                                
                                <container>
                                    <containerId>tomcat5x</containerId>
                                    <installerUrl>${tomcat.installer.url}</installerUrl>
                                    <containerHome>${base.webapp.directory}/fisheye/tomcat5x</containerHome>
                                    <outputLog>${base.webapp.directory}/fisheye/output.log</outputLog>
                                    <httpPort>${fisheye.http.port}</httpPort>
                                    <controlPort>${fisheye.rmi.port}</controlPort>
                                    <context>${fisheye.context.path}</context>
                                    <jvmArgs>${jvmargs} ${jvmargs.debug.fisheye}</jvmArgs>

                                    <startService>${fisheye.start}</startService>
                                </container>

                                <service>
                                    <removeJarFileRegexes>${fisheye.jars.to.remove.regex.list}</removeJarFileRegexes>
                                    <installThisArtifact>${fisheye.plugin.install}</installThisArtifact>
                                    <webappDirectory>
                                        ${base.webapp.directory}/fisheye/fisheye-webapp
                                    </webappDirectory>
                                </service>
                            </configuration>
                        </execution>
                        
                        <execution>
                            <id>start-confluence</id>
                            <goals>
                                <goal>start-confluence</goal>
                            </goals>
                            <phase>pre-integration-test</phase>
                            <configuration>
                                <version>${confluence.version}</version>
                                <testResourcesVersion>${confluence.data.version}</testResourcesVersion>

                                <container>
                                    <containerId>tomcat5x</containerId>
                                    <installerUrl>${tomcat.installer.url}</installerUrl>
                                    <containerHome>${base.webapp.directory}/confluence/tomcat5x</containerHome>
                                    <outputLog>${base.webapp.directory}/confluence/output.log</outputLog>
                                    <httpPort>${confluence.http.port}</httpPort>
                                    <controlPort>${confluence.rmi.port}</controlPort>
                                    <context>${confluence.context.path}</context>
                                    <jvmArgs>${jvmargs} ${jvmargs.debug.confluence}</jvmArgs>

                                    <startService>${confluence.start}</startService>
                                    <wait>${confluence.wait}</wait>
                                </container>

                                <service>
                                    <removeJarFileRegexes>${confluence.jars.to.remove.regex.list}</removeJarFileRegexes>
                                    <installThisArtifact>${confluence.plugin.install}</installThisArtifact>
                                    <bundledPlugin>${confluence.plugin.bundled}</bundledPlugin>
                                    <applicationDependencies>
                                        <!-- For full functionality of the test lib, it should be installed as part of the
                                       application -->
                                        <pluginDependency>
                                            <groupId>com.atlassian.confluence.plugin</groupId>
                                            <artifactId>func-test</artifactId>
                                            <version>${confluence.test-lib.version}</version>
                                        </pluginDependency>
                                    </applicationDependencies>
                                    <configDirectory>
                                        ${base.webapp.directory}/confluence/confluence-config
                                    </configDirectory>
                                    <webappDirectory>
                                        ${base.webapp.directory}/confluence/confluence-webapp
                                    </webappDirectory>
                                </service>
                            </configuration>
                        </execution>

                        <execution>
                            <id>start-jira</id>
                            <goals>
                                <goal>start-jira</goal>
                            </goals>
                            <phase>pre-integration-test</phase>
                            <configuration>
                                <version>${jira.version}</version>
                                <testResourcesVersion>${jira.data.version}</testResourcesVersion>
                                
                                <container>
                                    <containerId>tomcat5x</containerId>
                                    <installerUrl>${tomcat.installer.url}</installerUrl>
                                    <containerHome>${base.webapp.directory}/jira/tomcat5x</containerHome>
                                    <outputLog>${base.webapp.directory}/jira/output.log</outputLog>
                                    <httpPort>${jira.http.port}</httpPort>
                                    <controlPort>${jira.rmi.port}</controlPort>
                                    <context>${jira.context.path}</context>
                                    <jvmArgs>${jvmargs} ${jvmargs.debug.jira}</jvmArgs>

                                    <startService>${jira.start}</startService>
                                    <wait>${jira.wait}</wait>
                                </container>

                                <service>
                                    <removeJarFileRegexes>${jira.jars.to.remove.regex.list}</removeJarFileRegexes>
                                    <installThisArtifact>${jira.plugin.install}</installThisArtifact>
                                    <configDirectory>
                                        ${base.webapp.directory}/jira/jira-config
                                    </configDirectory>
                                    <webappDirectory>
                                        ${base.webapp.directory}/jira/jira-webapp
                                    </webappDirectory>
                                </service>
                            </configuration>
                        </execution>

                        <execution>
                            <id>start-bamboo</id>
                            <goals>
                                <goal>start-bamboo</goal>
                            </goals>
                            <phase>pre-integration-test</phase>
                            <configuration>
                                <version>${bamboo.version}</version>
                                <testResourcesVersion>${bamboo.data.version}</testResourcesVersion>

                                <container>
                                    <containerId>tomcat5x</containerId>
                                    <installerUrl>${tomcat.installer.url}</installerUrl>
                                    <containerHome>${base.webapp.directory}/bamboo/tomcat5x</containerHome>
                                    <outputLog>${base.webapp.directory}/bamboo/output.log</outputLog>
                                    <httpPort>${bamboo.http.port}</httpPort>
                                    <controlPort>${bamboo.rmi.port}</controlPort>
                                    <context>${bamboo.context.path}</context>
                                    <jvmArgs>${jvmargs} ${jvmargs.debug.bamboo}</jvmArgs>

                                    <startService>${bamboo.start}</startService>
                                    <wait>${bamboo.wait}</wait>
                                </container>

                                <service>
                                    <removeJarFileRegexes>${bamboo.jars.to.remove.regex.list}</removeJarFileRegexes>
                                    <installThisArtifact>${bamboo.plugin.install}</installThisArtifact>
                                    <configDirectory>
                                        ${base.webapp.directory}/bamboo/bamboo-config
                                    </configDirectory>
                                    <webappDirectory>
                                        ${base.webapp.directory}/bamboo/bamboo-webapp
                                    </webappDirectory>
                                </service>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <configuration>
                        <skip>${maven.test.unit.skip}</skip>
                        <excludes>
                            <exclude>it/**/*</exclude>
                            <exclude>**/*Abstract*</exclude>
                            <exclude>**/*Mock*</exclude>
                            <exclude>**/*$*</exclude>
                        </excludes>
                    </configuration>
                    <executions>
                        <execution>
                            <id>acceptance_tests</id>
                            <phase>integration-test</phase>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <configuration>
                                <skip>${maven.test.it.skip}</skip>
                                <excludes>
                                    <exclude>none</exclude>
                                    <exclude>**/*Abstract*</exclude>
                                    <exclude>**/*Mock*</exclude>
                                    <exclude>**/*$*</exclude>
                                </excludes>
                                <includes>
                                    <include>it/**/*java</include>
                                </includes>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <groupId>com.atlassian.maven.plugins</groupId>
                    <artifactId>atlassian-pdk</artifactId>
                    <version>2.1.5</version>
                    <configuration>
                        <extractDependencies>true</extractDependencies>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>
