<?xml version="1.0" encoding="UTF-8"?>
<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>net.officefloor.package</groupId>
		<artifactId>package</artifactId>
		<version>2.2.0</version>
	</parent>
	<artifactId>OfficeFloor</artifactId>
	<name>OfficeFloor Server</name>
	<description>Server for running OfficeFloor application</description>
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<packageProperties>WoOF
			officefloorsource=net.officefloor.plugin.woof.WoofOfficeFloorSource
			officefloor=WoOF
</packageProperties>
	</properties>
	<build>
		<plugins>
			<plugin>
				<!-- Generates the release -->
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-assembly-plugin</artifactId>
				<executions>
					<execution>
						<id>release</id>
						<phase>package</phase>
						<goals>
							<goal>single</goal>
						</goals>
						<configuration>
							<descriptors>
								<descriptor>release-assembly.xml</descriptor>
							</descriptors>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<!-- Integration test setup and teardown -->
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<executions>
					<execution>
						<id>integration test setup</id>
						<phase>pre-integration-test</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<target>
								<property name="binDir"
									value="${basedir}/target/OfficeFloor-${project.version}-release/OfficeFloor-${project.version}/bin" />

								<echo>Starting OfficeBuilding</echo>
								<chmod file="${binDir}/officebuilding" perm="555" />
								<exec dir="${binDir}" executable="${binDir}/officebuilding"
									spawn="true">
									<arg value="start" />
								</exec>
								<sleep seconds="5" /> <!-- allow time to start -->

								<echo>Opening FeatureApp</echo>
								<exec dir="${binDir}" executable="${binDir}/officebuilding"
									failonerror="false">
									<arg value="-a" />
									<arg
										value="net.officefloor.tutorial:FeatureApp:war:${project.version}" />
									<arg value="open" />
								</exec>
							</target>
						</configuration>
					</execution>
					<execution>
						<id>integration test teardown</id>
						<phase>post-integration-test</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<target>
								<property name="binDir"
									value="${basedir}/target/OfficeFloor-${project.version}-release/OfficeFloor-${project.version}/bin" />

								<echo>Stop OfficeBuilding</echo>
								<exec dir="${binDir}" executable="${binDir}/officebuilding"
									failonerror="true"> <!-- must always stop -->
									<arg value="stop" />
								</exec>
							</target>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-failsafe-plugin</artifactId>
				<executions>
					<execution>
						<id>failsafe-integration-test</id>
						<goals>
							<goal>integration-test</goal>
						</goals>
					</execution>
					<execution>
						<id>failsafe-verify</id>
						<goals>
							<goal>verify</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<!-- Test the install pom.xml (as OfficeFloor should now be built) -->
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-invoker-plugin</artifactId>
				<configuration>
					<projectsDirectory>${project.basedir}/../../src/site/resources</projectsDirectory>
					<cloneProjectsTo>${project.build.directory}/install</cloneProjectsTo>
					<pomIncludes>
						<pomInclude>pom.xml</pomInclude>
					</pomIncludes>
					<postBuildHookScript>../../verify.bsh</postBuildHookScript>
				</configuration>
				<executions>
					<execution>
						<id>test-install</id>
						<goals>
							<!-- Make this OfficeFloor release available -->
							<goal>install</goal>
							<goal>run</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
	<dependencies>
		<dependency>
			<groupId>net.officefloor.core</groupId>
			<artifactId>officebuilding</artifactId>
			<classifier>release</classifier>
			<type>zip</type>
		</dependency>
		<dependency>
			<groupId>net.officefloor.plugin</groupId>
			<artifactId>officeplugin_war</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpclient</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>
</project>