<?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">

	<parent>
		<groupId>com.atlassian.rm</groupId>
		<artifactId>portfolio</artifactId>
		<version>9.16.1</version>
		<relativePath>../pom.xml</relativePath>
	</parent>

	<artifactId>portfolio-client</artifactId>
	<modelVersion>4.0.0</modelVersion>
	<packaging>jar</packaging>

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

	<properties>

		<webpack.scripts.config>webpack-conf/prod/webpack.scripts.js</webpack.scripts.config>
		<webpack.styles.config>webpack-conf/prod/webpack.styles.js</webpack.styles.config>
		<maven.build.cache.exclude.portfolioClientNodeModules>${project.basedir}/nodeModules</maven.build.cache.exclude.portfolioClientNodeModules>

	</properties>

	<dependencies>

		<dependency>
			<groupId>com.atlassian.rm</groupId>
			<artifactId>common-frontend-configuration</artifactId>
			<version>${project.version}</version>
			<type>pom</type>
		</dependency>

		<dependency>
			<groupId>com.atlassian.rm</groupId>
			<artifactId>common-client</artifactId>
			<type>pom</type>
		</dependency>

		<dependency>
			<groupId>com.atlassian.rm</groupId>
			<artifactId>team-management-client-common</artifactId>
			<version>${project.version}</version>
			<type>pom</type>
		</dependency>

	</dependencies>

	<build>

		<pluginManagement>

			<plugins>

				<!-- client builds -->

				<plugin>

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

					<executions>


						<execution>

							<id>webpack-build-scripts</id>
							<phase>generate-resources</phase>
							<goals>
								<goal>exec</goal>
							</goals>

							<configuration>

								<executable>${node.executable}</executable>

								<arguments>
									<argument>${basedir}/${node.modules.bin}/${webpack.executable}</argument>
									<argument>-p</argument>
									<argument>--config</argument>
									<argument>${webpack.scripts.config}</argument>
								</arguments>

							</configuration>

						</execution>

						<execution>

							<id>webpack-build-styles</id>
							<phase>generate-resources</phase>
							<goals>
								<goal>exec</goal>
							</goals>

							<configuration>

								<executable>${node.executable}</executable>

								<arguments>
									<argument>${basedir}/${node.modules.bin}/${webpack.executable}</argument>
									<argument>-p</argument>
									<argument>--config</argument>
									<argument>${webpack.styles.config}</argument>
								</arguments>

							</configuration>

						</execution>

					</executions>

				</plugin>

			</plugins>

		</pluginManagement>

	</build>

	<profiles>

		<profile>

			<id>client-unit-tests</id>
			<activation>
				<property>
					<name>!skipTests</name>
				</property>
			</activation>

			<build>

				<pluginManagement>

					<plugins>

						<plugin>

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

							<executions>

								<execution>

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

									<configuration>

										<executable>${node.executable}</executable>

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

									</configuration>

								</execution>

							</executions>

						</plugin>

					</plugins>

				</pluginManagement>

			</build>

		</profile>

		<profile>

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

			<build>

				<plugins>

					<plugin>
						<groupId>com.github.eirslett</groupId>
						<artifactId>frontend-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>yarn install</id>
								<goals>
									<goal>yarn</goal>
								</goals>
								<configuration>
									<arguments>install --frozen-lockfile --prefer-offline --mutex network --no-progress</arguments>
								</configuration>
								<phase>initialize</phase>
								<inherited>false</inherited>
							</execution>
						</executions>
					</plugin>

					<plugin>

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

					</plugin>

				</plugins>

			</build>

		</profile>

		<profile>

			<id>clean-node-modules</id>
			<activation>
				<property>
					<name>cleanNodeModules</name>
				</property>
			</activation>

			<build>

				<plugins>

					<plugin>

						<artifactId>maven-clean-plugin</artifactId>

						<configuration>
							<filesets>
								<fileset>
									<directory>${basedir}</directory>
									<includes>
										<include>node_modules/</include>
									</includes>
								</fileset>
							</filesets>
						</configuration>

					</plugin>

				</plugins>

			</build>

		</profile>

	</profiles>

</project>
