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

	<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>com.atlassian.jpo</groupId>
		<artifactId>common</artifactId>
		<version>1.11.0-OD-001-D20151109T062348</version>
		<relativePath>../pom.xml</relativePath>
	</parent>

	<artifactId>common-client</artifactId>

	<name>Portfolio 2 / Common [Client]</name>

	<build>
		<!-- "exporting" is handled via gulp/grunt only -->
		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<excludes>
					<exclude>**/*.*</exclude>
				</excludes>
			</resource>
		</resources>
	</build>

	<profiles>

		<profile>

			<id>client-build</id>
			<activation>
				<property>
					<name>!skipClient</name>
				</property>
			</activation>

			<build>

				<plugins>

					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<version>1.3.2</version>

						<executions>

							<execution>
								<id>grunt-build</id>
								<phase>generate-resources</phase>
								<goals>
									<goal>exec</goal>
								</goals>
								<configuration>

									<executable>${node.modules.bin}/${grunt.executable}</executable>

									<environmentVariables>
										<PATH>
											${env.PATH}${path.separator}${node.modules.bin}${path.separator}${node.bin}
										</PATH>
									</environmentVariables>
								</configuration>
							</execution>

							<execution>
								<id>grunt-clean</id>
								<phase>clean</phase>
								<goals>
									<goal>exec</goal>
								</goals>
								<configuration>

									<executable>${node.modules.bin}/${grunt.executable}</executable>

									<arguments>
										<argument>clean</argument>
									</arguments>
								</configuration>
							</execution>

							<execution>
								<id>jasmine-unit-tests</id>
								<phase>test</phase>
								<goals>
									<goal>exec</goal>
								</goals>
								<configuration>

									<executable>${node.modules.bin}/${karma.executable}</executable>
									<arguments>
										<argument>start</argument>
										<argument>karma.conf.js</argument>
									</arguments>

								</configuration>
							</execution>

						</executions>

					</plugin>

					<!-- install node/npm locally -->
					<plugin>
						<groupId>com.github.eirslett</groupId>
						<artifactId>frontend-maven-plugin</artifactId>
						<version>${frontend.maven.plugin.version}</version>

						<executions>

							<!-- note that the following two executions are defined twice, once for phase clean and once
								 for phase generate-resources -->

							<execution>

								<id>phase-clean-nodeandnpm</id>
								<goals>
									<goal>install-node-and-npm</goal>
								</goals>
								<phase>pre-clean</phase>
								<configuration>
									<nodeVersion>${node.version}</nodeVersion>
									<npmVersion>${npm.version}</npmVersion>
								</configuration>

							</execution>

							<execution>

								<id>phase-clean-npminstall</id>
								<goals>
									<goal>npm</goal>
								</goals>
								<phase>pre-clean</phase>
								<configuration>
									<arguments>install</arguments>
								</configuration>

							</execution>

							<execution>

								<id>phase-generate-resource-nodeandnpm</id>
								<goals>
									<goal>install-node-and-npm</goal>
								</goals>
								<phase>validate</phase>
								<configuration>
									<nodeVersion>${node.version}</nodeVersion>
									<npmVersion>${npm.version}</npmVersion>
								</configuration>

							</execution>

							<execution>

								<id>phase-generate-resources-npminstall</id>
								<goals>
									<goal>npm</goal>
								</goals>
								<phase>initialize</phase>
								<configuration>
									<arguments>install</arguments>
								</configuration>

							</execution>

						</executions>
					</plugin>

				</plugins>

			</build>

		</profile>

	</profiles>

</project>