<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/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<parent> 
		<groupId>eu.gradesystem</groupId>
		<artifactId>grade</artifactId>
		<version>2.0.0-ea-SNAPSHOT</version>
	</parent>

	<artifactId>grade-head</artifactId>
	<packaging>war</packaging>

	<properties>
		<frontend-resources>${project.build.directory}/frontend-resources</frontend-resources>
		<profile>default</profile>
	</properties>

	<dependencies>

		<dependency>
			<groupId>eu.gradesystem</groupId>
			<artifactId>grade-console</artifactId>
			<version>${project.version}</version>
			<type>tar.gz</type>
			<classifier>resources</classifier>
			<scope>runtime</scope>
		</dependency>




		<dependency>
			<groupId>eu.gradesystem</groupId>
			<artifactId>grade-common</artifactId>
		</dependency>

		<dependency>
			<groupId>eu.gradesystem</groupId>
			<artifactId>grade-service</artifactId>
		</dependency>

		<!-- weld -->

		<dependency>
			<groupId>javax.enterprise</groupId>
			<artifactId>cdi-api</artifactId>
		</dependency>

		<dependency>
			<groupId>org.jboss.weld.servlet</groupId>
			<artifactId>weld-servlet</artifactId>
		</dependency>

		<dependency>
			<groupId>org.jboss</groupId>
			<artifactId>jandex</artifactId>
		</dependency>

		<!-- jersey -->

		<dependency>
			<groupId>javax.ws.rs</groupId>
			<artifactId>javax.ws.rs-api</artifactId>
		</dependency>

		<dependency>
			<groupId>org.glassfish.jersey.media</groupId>
			<artifactId>jersey-media-multipart</artifactId>
		</dependency>

		<dependency>
			<groupId>org.glassfish.jersey.containers</groupId>
			<artifactId>jersey-container-servlet</artifactId>
		</dependency>

		<dependency>
			<groupId>org.glassfish.jersey.containers.glassfish</groupId>
			<artifactId>jersey-gf-cdi</artifactId>
		</dependency>

		<dependency>
			<groupId>javax.transaction</groupId>
			<artifactId>javax.transaction-api</artifactId>
		</dependency>


		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>3.0.1</version>
			<scope>provided</scope>
		</dependency>


	</dependencies>



	<build>

		<plugins>

			<!-- Tomcat plugin -->
			<plugin>
				<groupId>org.apache.tomcat.maven</groupId>
				<artifactId>tomcat7-maven-plugin</artifactId>
				<version>2.2</version>
				<configuration>
					<port>9090</port>
					<path>/grade</path>
					<username>tomcat</username>
					<password>tomcat</password>
					<systemProperties>
						<grade.config>${basedir}/target</grade.config>
					</systemProperties>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<version>2.8</version>
				<executions>
					<execution>
						<id>unpack-resources</id>
						<phase>prepare-package</phase>
						<goals>
							<goal>unpack-dependencies</goal>
						</goals>
						<configuration>
							<classifier>resources</classifier>
							<outputDirectory>${frontend-resources}</outputDirectory>
							<overWriteReleases>false</overWriteReleases>
							<overWriteSnapshots>true</overWriteSnapshots>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<version>2.4</version>
				<configuration>
					<webResources>
						<resource>
							<directory>${frontend-resources}</directory>
						</resource>
					</webResources>
					<failOnMissingWebXml>false</failOnMissingWebXml>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-resources-plugin</artifactId>
				<version>2.6</version>
				<configuration>
					<outputDirectory>${project.build.directory}/classes</outputDirectory>
					<resources>
						<resource>
							<directory>${basedir}/profiles/${grade.config.dir}</directory>
							<filtering>true</filtering>
						</resource>
					</resources>
				</configuration>
				<executions>
					<execution>
						<phase>prepare-package</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
					</execution>
				</executions>
			</plugin>


		</plugins>

	</build>

	<profiles>

		<profile>

			<id>mem</id>

			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>

			<properties>
				<grade.config.dir>mem</grade.config.dir>
			</properties>

		</profile>

	</profiles>

</project>