<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.confluence.plugin.base</groupId>
    <artifactId>confluence-plugin-base</artifactId>
    <version>6</version>
    <packaging>pom</packaging>
    <name>Confluence Plugin Base</name>
    <description>
        Parent POM for Confluence plugins. Specifies which version of Java to compile
        against, and Maven repositories for Confluence and its dependencies.
    </description>

    <scm>
        <url>https://svn.atlassian.com/svn/public/atlassian/confluence/plugins/confluence-plugin-base/tags/confluence-plugin-base-6</url>
        <connection>scm:svn:https://svn.atlassian.com/svn/public/atlassian/confluence/plugins/confluence-plugin-base/tags/confluence-plugin-base-6</connection>
        <developerConnection>scm:svn:https://svn.atlassian.com/svn/public/atlassian/confluence/plugins/confluence-plugin-base/tags/confluence-plugin-base-6</developerConnection>
    </scm>

    <build>
	<plugins>
                <plugin>
                        <groupId>com.atlassian.maven.plugins</groupId>
                        <artifactId>maven-clover-plugin</artifactId>
                </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.4</source>
                        <target>1.4</target>
                    </configuration>
                </plugin>
				<plugin>
					<!--
						Use the dependency plugin to extract the default Confluence configuration for acceptance tests into the test confluence.home directory
					-->
					<artifactId>maven-dependency-plugin</artifactId>
					<version>2.0-alpha-4</version>
					<executions>
						<execution>
							<id>unpack-confluence-config</id>
							<phase>pre-integration-test</phase>
							<goals>
								<goal>unpack</goal>
							</goals>
							<configuration>
								<artifactItems>
									<artifactItem>
										<groupId>com.atlassian.confluence.plugins</groupId>
										<artifactId>confluence-plugin-test-resources</artifactId>
									</artifactItem>
								</artifactItems>
								<outputDirectory>
									${confluence.config.directory}
								</outputDirectory>
							</configuration>
						</execution>
						
						<execution>
							<id>gather-dependencies</id>
							<phase>compile</phase>
							<goals>
								<goal>copy-dependencies</goal>
							</goals>
							<configuration>
								<outputDirectory>${project.build.directory}/classes/META-INF/lib/</outputDirectory>
								<excludeTransitive>true</excludeTransitive>
								<includeScope>runtime</includeScope>
								<excludeScope>provided</excludeScope>
								<excludeScope>test</excludeScope>
								<excludeScope>compile</excludeScope>
							</configuration>
						</execution>
						
					</executions>
				</plugin>
	
				<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="${confluence.config.directory}/confluence-home/confluence.cfg.xml" token="@project-dir@" value="${confluence.config.directory}" />
                                </tasks>
                            </configuration>
                        </execution>
						<execution>
							<id>copy-plugin-artifact</id>
							<phase>pre-integration-test</phase>
							<goals>
								<goal>run</goal>
							</goals>
							<configuration>
								<tasks>
									<echo file="${project.build.directory}/test-classes/${project.build.finalName}.properties">
# Maven settings
maven.junit.fork=once
acceptance.tests=default

# Cargo settings
cargo.container.containerid=tomcat5x
http.port=${http.port}
controller.port=${rmi.port}
smtp.port=${smtp.port}

# Acceptance test settings
baseurl=${confluence.url}
webappContext=confluence
database.type=database-type-embedded
									</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>
							<systemProperties>
								<acceptanceTestSettings>
									${project.build.finalName}.properties
								</acceptanceTestSettings>
								<confluence.home>
									${confluence.config.directory}/confluence-home
								</confluence.home>
							</systemProperties>
						</container>
						<configuration>
							<home>
								${project.build.directory}/tomcat5x/container
							</home>
							<properties>
								<cargo.servlet.port>
									${http.port}
								</cargo.servlet.port>
								<cargo.rmi.port>${rmi.port}</cargo.rmi.port>
								<cargo.jvmargs>${jvmargs}</cargo.jvmargs>
							</properties>
							<deployables>
								<deployable>
									<groupId>
										com.atlassian.confluence
									</groupId>
									<artifactId>
										confluence-webapp
									</artifactId>
									<type>war</type>
									<properties>
										<context>confluence</context>
									</properties>
									<pingURL>${confluence.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.confluence</groupId>
			<artifactId>confluence</artifactId>
			<version>${confluence.version}</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>com.atlassian.confluence</groupId>
			<artifactId>confluence-webapp</artifactId>
			<version>${confluence.version}</version>
			<type>war</type>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>com.atlassian.confluence.plugins</groupId>
			<artifactId>confluence-plugin-test-resources</artifactId>
			<version>${confluence.data.version}</version>
			<type>zip</type>
			<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>
		<confluence.config.directory>${project.build.directory}</confluence.config.directory>
		<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>

		<confluence.url>http://localhost:${http.port}/confluence</confluence.url>
		<confluence.version>2.6.0</confluence.version>
		<confluence.data.version>2.6</confluence.data.version>
		<http.port>9999</http.port>
		<smtp.port>20196</smtp.port>
		<cargo.wait>false</cargo.wait>
		<rmi.port>9899</rmi.port>
	</properties>
</project>
