<?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">
	<modelVersion>4.0.0</modelVersion>

	<parent>
        <groupId>ch.admin.bit.jeap</groupId>
        <artifactId>jeap-error-handling-parent</artifactId>
		<version>16.7.0</version>
    </parent>

	<artifactId>jeap-error-handling-ui</artifactId>
	<name>${project.groupId}:${project.artifactId}</name>
	<packaging>jar</packaging>

	<build>
		<pluginManagement>
			<plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>3.0.0</version>
                </plugin>
			</plugins>
		</pluginManagement>
	</build>

	<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>
						<executions>
							<execution>
								<id>npm</id>
								<phase>generate-resources</phase>
								<goals>
									<goal>exec</goal>
								</goals>
								<configuration>
									<executable>npm</executable>
									<arguments>
										<argument>ci</argument>
									</arguments>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>ng-build</id>
			<activation>
				<file>
					<missing>target/classes/static/</missing> <!-- Execute if the output of ng build is not present -->
				</file>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<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>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>
