<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>es.uvigo.esei.dgss.teamA.microstories</groupId>
		<artifactId>dgss2324-teamA-microstories-pom</artifactId>
		<version>0.2.0-SNAPSHOT</version>
	</parent>
	<artifactId>dgss2324-teamA-microstories-web</artifactId>
	<packaging>war</packaging>

	<name>Web</name>
	<description>μStories 23/24 Team A - Web</description>

	<dependencies>
		<!-- General -->
		<dependency>
			<groupId>javax</groupId>
			<artifactId>javaee-api</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>${project.groupId}</groupId>
			<artifactId>dgss2324-teamA-microstories-service</artifactId>
			<scope>provided</scope>
		</dependency>
	</dependencies>

	<build>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>com.github.eirslett</groupId>
					<artifactId>frontend-maven-plugin</artifactId>
					<configuration>
						<nodeVersion>${node.version}</nodeVersion>
						<workingDirectory>${project.basedir}/src/main/angular</workingDirectory>
					</configuration>
				</plugin>
			</plugins>
		</pluginManagement>

		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-clean-plugin</artifactId>
				<configuration>
					<filesets>
						<fileset>
							<directory>${project.basedir}/src/main/angular/</directory>
							<includes>
								<include>node_modules/</include>
								<include>node/</include>
								<include>.angular/</include>
							</includes>
						</fileset>
						<fileset>
							<directory>${project.basedir}/src/main/webapp/</directory>
							<excludes>
								<exclude>WEB-INF/</exclude>
								<exclude>.gitignore</exclude>
							</excludes>
						</fileset>
					</filesets>
				</configuration>
			</plugin>
			
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<executions>
					<execution>
						<phase>process-resources</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<target>
								<delete>
									<fileset dir="${project.basedir}/src/main/webapp/">
										<exclude name="WEB-INF"/>
										<exclude name=".gitignore"/>
									</fileset>
								</delete>
							</target>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>com.github.eirslett</groupId>
				<artifactId>frontend-maven-plugin</artifactId>
				<executions>
					<execution>
						<id>build-application</id>
						<goals>
							<goal>npx</goal>
						</goals>
						<phase>compile</phase>
						<configuration>
							<arguments>npm run build</arguments>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

	<profiles>
		<profile>
			<id>install-node-and-npm</id>
			<activation>
				<file>
					<missing>${basedir}/src/main/angular/node</missing>
				</file>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>com.github.eirslett</groupId>
						<artifactId>frontend-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>install-node-and-npm</id>
								<goals>
									<goal>install-node-and-npm</goal>
								</goals>
								<phase>generate-resources</phase>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>install-npm-dependencies</id>
			<activation>
				<file>
					<missing>${basedir}/src/main/angular/node_modules</missing>
				</file>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>com.github.eirslett</groupId>
						<artifactId>frontend-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>install-npm-dependencies</id>
								<goals>
									<goal>npx</goal>
								</goals>
								<phase>generate-resources</phase>
								<configuration>
									<arguments>npm install</arguments>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
</project>
