<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.armundia</groupId>
        <artifactId>stub-pom</artifactId>
        <version>0.0.1-SNAPSHOT</version>
		<relativePath>../stub-pom/pom.xml</relativePath>
    </parent>

    <artifactId>stub-gui</artifactId>

    <properties>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <sonar.exclusions>node_modules/**,release/**, node/**, source/libs/**, target/**</sonar.exclusions>
        <sonar.sources>source</sonar.sources>
    </properties>

    <profiles>
        <profile>
            <id>production</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <!-- Gestisce la compilazione del front
                            - Scarica ed installa le versioni corrette di node ed npm (nella cartella node)
                            - lancia il comando npm per il build
                        -->
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>1.11.3</version>

                        <executions>
                            <execution>
                                <id>install node and npm</id>
                                <goals>
                                    <goal>install-node-and-npm</goal>
                                </goals>
                                <configuration>
                                    <nodeVersion>v16.13.2</nodeVersion>
                                    <npmVersion>8.4.0</npmVersion>
                                </configuration>
                            </execution>
                            <execution>
                                <id>npm run build</id>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>run build-prod-m</arguments>
                                </configuration>
                            </execution>

                        </executions>
                    </plugin>

                    <plugin>
                        <!-- Gestisco la copia dei file compilati all'interno del progetto web in modo che
                            il jar generato abbia tutto il necessario -->
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>3.3.0</version>
                        <executions>
                            <execution>
                                <id>copy-resources</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${basedir}/../stub-war/src/main/webapp/app</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>release</directory>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <!-- Evitare la generazione del jar visto che siamo in un progetto gui -->
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>3.3.0</version>
                        <executions>
                            <execution>
                                <id>default-jar</id>
                                <phase>none</phase>
                                <configuration>
                                    <finalName>unwanted</finalName>
                                    <classifier>unwanted</classifier>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <!-- Evitare lo step di install ... 
                            non è un progetto pom vero ma un progetto GUI,
                            ci pensa il copy-resources
                            a spostare il compilato all'interno del progetto web -->
                        <artifactId>maven-install-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <execution>
                                <id>default-install</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>