<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.pom</groupId>
        <artifactId>atlassian-public-pom</artifactId>
        <version>9</version>
    </parent>

	<groupId>com.atlassian.jira.plugins</groupId>
	<artifactId>jira-plugin-base</artifactId>
	<packaging>pom</packaging>
	<name>JIRA Plugin Test Base</name>
	<version>5</version>

	<scm>
		<connection>scm:svn:http://svn.atlassian.com/svn/public/atlassian/jira/plugins/jira-plugin-base/tags/jira-plugin-base-5</connection>
		<developerConnection>scm:svn:https://svn.atlassian.com/svn/public/atlassian/jira/plugins/jira-plugin-base/tags/jira-plugin-base-5</developerConnection>
		<url>http://svn.atlassian.com/fisheye/browse/public/atlassian/jira/plugins/jira-plugin-base/tags/jira-plugin-base-5</url>
	</scm>

    <build>
	<plugins>
        <plugin>
            <groupId>com.atlassian.maven.plugins</groupId>
            <artifactId>maven-clover-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>com.atlassian.maven.plugins</groupId>
            <artifactId>atlassian-pdk</artifactId>
            <extensions>true</extensions>
        </plugin>
    </plugins>
		<pluginManagement>
			<plugins>
				<plugin>
					<artifactId>maven-dependency-plugin</artifactId>
					<version>2.0-alpha-4</version>

					<executions>
						<execution>
							<id>unpack-jira-config</id>
							<phase>pre-integration-test</phase>
							<goals>
								<goal>unpack</goal>
							</goals>
							<configuration>
                                <artifactItems>
									<artifactItem>
										<groupId>
											com.atlassian.jira.plugins
										</groupId>
										<artifactId>
											jira-plugin-test-resources
										</artifactId>
                                    </artifactItem>
                                </artifactItems>
                                <outputDirectory>
									${jira.config.directory}
								</outputDirectory>
                                <markersDirectory>${jira.config.directory}/dependency-plugin-markers</markersDirectory>
                            </configuration>
						</execution>

						<execution>
							<id>unpack-jira-war</id>
							<phase>pre-integration-test</phase>
							<goals>
								<goal>unpack</goal>
							</goals>
							<configuration>
								<artifactItems>
									<artifactItem>
										<groupId>
											com.atlassian.jira
										</groupId>
										<artifactId>
											atlassian-jira-webapp
										</artifactId>
										<type>war</type>
									</artifactItem>
								</artifactItems>
								<outputDirectory>
									${tmp.webapp.dir}
								</outputDirectory>
							</configuration>
						</execution>

						<execution>
							<id>gather-dependencies</id>
							<phase>pre-integration-test</phase>
							<goals>
								<goal>copy-dependencies</goal>
							</goals>
							<configuration>
								<outputDirectory>
									${tmp.webapp.dir}/WEB-INF/lib/
								</outputDirectory>
								<excludeTransitive>
									true
								</excludeTransitive>
								<includeScope>runtime</includeScope>
								<excludeScope>provided</excludeScope>
								<excludeScope>test</excludeScope>
								<excludeScope>compile</excludeScope>
							</configuration>
						</execution>
					</executions>
				</plugin>
                <!--
					NB:
					the last two execution above and the next plugin are providing for static plugin deployment in JIRA
					the only way to do that at the moment is by creating a WAR structure and merging it with JIRA WAR, deployed in the container
					once JIRA has been successfully :-) migrated to the new plugin ways (i.e. dynamic plugin deployment etc..) - 
					we can get rid of all this mess and do what Confluence test framework does   
				-->
				<plugin>
					<artifactId>maven-antrun-plugin</artifactId>
					<version>1.1</version>
					<executions>
                        <execution>
                            <id>update-paths</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                            <configuration>
                                <tasks>
                                    <replace file="${jira.config.directory}/jira-home/database.script" token="@project-dir@" value="${jira.config.directory}" />
                                </tasks>
                            </configuration>
                        </execution>
                        <execution>
							<id>copy-plugin-artifact</id>
							<phase>pre-integration-test</phase>
							<goals>
								<goal>run</goal>
							</goals>
							<configuration>
								<tasks>
									<copy file="${project.artifact.file}" todir="${tmp.webapp.dir}/WEB-INF/lib/" />
									<echo file="${project.build.directory}/test-classes/localtest.properties">
										jira.protocol=http
										jira.host=localhost
										jira.context=/jira
										jira.tmp=${project.build.directory}/test-tmp/
										jira.xml.data.location=src/test/xml/
										jira.port=${http.port}
										jira.edition=enterprise
									</echo>
								</tasks>
							</configuration>
						</execution>
					</executions>
				</plugin>

				<plugin>
					<groupId>org.codehaus.cargo</groupId>
					<artifactId>cargo-maven2-plugin</artifactId>
					<version>0.3.1</version>
					<executions>
						<execution>
							<id>start-container</id>
							<phase>pre-integration-test</phase>
							<goals>
								<goal>start</goal>
							</goals>
						</execution>
					</executions>
					<configuration>
						<wait>${cargo.wait}</wait>
						<container>
							<containerId>tomcat5x</containerId>
							<zipUrlInstaller>
								<url>${tomcat.installer.url}</url>
							</zipUrlInstaller>
							<output>
								${project.build.directory}/output.log
							</output>
							<log>
								${project.build.directory}/cargo-log.log
							</log>

							<!-- The following dependencies are needed by JIRA when it is runnning inside the Tomcat for JNDI and data source -->
							<dependencies>
								<dependency>
									<groupId>hsqldb</groupId>
									<artifactId>hsqldb</artifactId>
								</dependency>
								<dependency>
									<groupId>jta</groupId>
									<artifactId>jta</artifactId>
								</dependency>
								<dependency>
									<groupId>ots-jts</groupId>
									<artifactId>ots-jts</artifactId>
								</dependency>
								<!-- Jars for DataSource and TransactionManager providers -->
								<dependency>
									<groupId>jotm</groupId>
									<artifactId>jotm</artifactId>
								</dependency>
								<dependency>
									<groupId>jotm</groupId>
									<artifactId>
										jotm-jrmp_stubs
									</artifactId>
								</dependency>
								<dependency>
									<groupId>jotm</groupId>
									<artifactId>
										jotm-iiop_stubs
									</artifactId>
								</dependency>
								<dependency>
									<groupId>jotm</groupId>
									<artifactId>jonas_timer</artifactId>
								</dependency>
								<dependency>
									<groupId>jotm</groupId>
									<artifactId>
										objectweb-datasource
									</artifactId>
								</dependency>
								<dependency>
									<groupId>carol</groupId>
									<artifactId>carol</artifactId>
								</dependency>
								<dependency>
									<groupId>carol</groupId>
									<artifactId>
										carol-properties
									</artifactId>
								</dependency>
								<dependency>
									<groupId>xapool</groupId>
									<artifactId>xapool</artifactId>
								</dependency>
							</dependencies>
						</container>
						<configuration>
							<home>
								${project.build.directory}/tomcat5x/container
							</home>
							<properties>
								<cargo.datasource.datasource>
									cargo.datasource.url=jdbc:hsqldb:${jira.config.directory}/jira-home/database|
									cargo.datasource.driver=org.hsqldb.jdbcDriver|
									cargo.datasource.username=sa|
									cargo.datasource.password=|
									cargo.datasource.type=javax.sql.DataSource|
									cargo.datasource.jndi=jdbc/JiraDS
								</cargo.datasource.datasource>
								<cargo.servlet.port>
									${http.port}
								</cargo.servlet.port>
								<cargo.rmi.port>
									${rmi.port}
								</cargo.rmi.port>
								<cargo.jvmargs>
									${jvmargs}
								</cargo.jvmargs>
							</properties>

							<deployables>
								<deployable>
									<location>
										${tmp.webapp.dir}
									</location>
									<type>war</type>
									<properties>
										<context>jira</context>
									</properties>
									<pingURL>${jira.url}</pingURL>
									<pingTimeout>60000</pingTimeout>
								</deployable>
							</deployables>
						</configuration>
					</configuration>
				</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>
			</plugins>
		</pluginManagement>
	</build>

	<dependencies>
		<dependency>
			<groupId>com.atlassian.jira</groupId>
			<artifactId>atlassian-jira-webapp</artifactId>
			<version>${jira.version}</version>
			<type>war</type>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>com.atlassian.jira</groupId>
			<artifactId>atlassian-jira</artifactId>
			<version>${jira.version}</version>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>com.atlassian.jira</groupId>
			<artifactId>jira-func-tests</artifactId>
			<version>${jira.test-lib.version}</version>
			<scope>provided</scope>
		</dependency>

		<!--	
			Should the test resources below mimic the JIRA versions as well? 
			That would make it possible to change test resources from  version to version using a variable in the builds 
		-->
		<dependency>
			<groupId>com.atlassian.jira.plugins</groupId>
			<artifactId>jira-plugin-test-resources</artifactId>
			<version>${jira.data.version}</version>
			<type>zip</type>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>hsqldb</groupId>
			<artifactId>hsqldb</artifactId>
			<version>1.8.0.5</version>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>jta</groupId>
			<artifactId>jta</artifactId>
			<version>1.0.1</version>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>ots-jts</groupId>
			<artifactId>ots-jts</artifactId>
			<version>1.0</version>
			<scope>provided</scope>
		</dependency>
		<!-- Jars for DataSource and TransactionManager providers -->
		<dependency>
			<groupId>jotm</groupId>
			<artifactId>jotm</artifactId>
			<version>1.4.3</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>jotm</groupId>
			<artifactId>jotm-jrmp_stubs</artifactId>
			<version>1.4.3</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>jotm</groupId>
			<artifactId>jotm-iiop_stubs</artifactId>
			<version>1.4.3</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>jotm</groupId>
			<artifactId>jonas_timer</artifactId>
			<version>1.4.3</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>jotm</groupId>
			<artifactId>objectweb-datasource</artifactId>
			<version>1.4.3</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>carol</groupId>
			<artifactId>carol</artifactId>
			<version>1.5.2</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>carol</groupId>
			<artifactId>carol-properties</artifactId>
			<version>1.0</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>xapool</groupId>
			<artifactId>xapool</artifactId>
			<version>1.3.1</version>
			<scope>provided</scope>
		</dependency>
	</dependencies>

	<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>http://repository.atlassian.com/maven2/org/apache/tomcat/apache-tomcat/5.5.20/apache-tomcat-5.5.20-jdk14.zip</tomcat.installer.url>
		<tmp.webapp.dir>${project.build.directory}/jira-webapp/</tmp.webapp.dir><!-- this is simply a global variable for convenience. don't bother altering this location -->
		<cargo.wait>false</cargo.wait>

        <jira.config.directory>${project.build.directory}</jira.config.directory>
        <unpack.jira.config.overwrite>true</unpack.jira.config.overwrite>

        <jira.version>3.11</jira.version>
	<jira.test-lib.version>3.11</jira.test-lib.version>
	<jira.data.version>3.11</jira.data.version>


        <http.port>1990</http.port>
	<jira.url>http://localhost:${http.port}/jira</jira.url>
	<rmi.port>${http.port}1</rmi.port>
	</properties>
</project>
