<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		 xmlns="http://maven.apache.org/POM/4.0.0"
		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<parent>
		<groupId>ch.admin.bit.jeap</groupId>
		<artifactId>jeap-process-context-service</artifactId>
		<version>20.5.0</version>
	</parent>
	<modelVersion>4.0.0</modelVersion>

	<artifactId>jeap-process-context-ui</artifactId>
	<name>${project.groupId}:${project.artifactId}</name>

	<properties>
		<exec-maven-plugin.version>3.5.0</exec-maven-plugin.version>
	</properties>

	<profiles>
		<profile>
			<id>npm-install</id>
			<activation>
				<file>
					<missing>node_modules</missing> <!-- Execute if node_modules/ is not present -->
				</file>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<version>${exec-maven-plugin.version}</version>
						<executions>
							<execution>
								<id>npm</id>
								<phase>generate-resources</phase>
								<goals>
									<goal>exec</goal>
								</goals>
								<configuration>
									<executable>npm</executable>
									<arguments>
										<argument>ci</argument>
										<argument>--force</argument>
									</arguments>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>build-frontend</id>
			<activation>
				<property>
					<name>!pipeline.build.step.publish</name>
				</property>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<version>${exec-maven-plugin.version}</version>
						<executions>
							<execution>
								<id>generate-license-file</id>
								<phase>process-resources</phase>
								<goals>
									<goal>exec</goal>
								</goals>
								<configuration>
									<executable>npm</executable>
									<arguments>
										<argument>run</argument>
										<argument>generateLicenseFile</argument>
									</arguments>
								</configuration>
							</execution>
							<execution>
								<id>check-licenses</id>
								<phase>verify</phase>
								<goals>
									<goal>exec</goal>
								</goals>
								<configuration>
									<executable>npm</executable>
									<arguments>
										<argument>run</argument>
										<argument>check-licenses</argument>
									</arguments>
								</configuration>
							</execution>
							<execution>
								<id>cypress-test</id>
								<phase>test</phase>
								<goals>
									<goal>exec</goal>
								</goals>
								<configuration>
									<executable>${project.basedir}/startCypress.sh</executable>
									<skip>${maven.test.skip}</skip>
								</configuration>
							</execution>
							<execution>
								<id>test</id>
								<phase>process-resources</phase>
								<goals>
									<goal>exec</goal>
								</goals>
								<configuration>
									<skip>${maven.test.skip}</skip>
									<executable>npm</executable>
									<arguments>
										<argument>run</argument>
										<argument>test</argument>
										<argument>--</argument>
										<argument>--watch=false</argument>
									</arguments>
								</configuration>
							</execution>
							<execution>
								<id>build-prod</id>
								<phase>process-resources</phase>
								<goals>
									<goal>exec</goal>
								</goals>
								<configuration>
									<executable>npm</executable>
									<arguments>
										<argument>run</argument>
										<argument>build-prod</argument>
									</arguments>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
</project>
