<?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">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.oney</groupId>
    <artifactId>oney-parent-18</artifactId>
    <version>2.1.0</version>
  </parent>
  <groupId>com.oney.isaac.front</groupId>
  <artifactId>isaac-front</artifactId>
  <version>1.0.22</version>
  <packaging>pom</packaging>

  <properties>
    <maven-war-plugin.version>3.1.0</maven-war-plugin.version>
    <maven-exec-plugin.version>1.6.0</maven-exec-plugin.version>
    <project.scm.id>gitlab.banque-accord.com</project.scm.id>
  </properties>

  <scm>
    <connection>scm:git:http://gitlab.oney.fr/ISAAC/isaac-front.git</connection>
     <tag>isaac-front-1.0.22</tag>
  </scm> 
  
  <profiles>
    <profile>
      <id>build-war-properties-windows</id>
      <activation>
        <os>
          <family>windows</family>
        </os>
      </activation>
      <properties>
        <executable.npm>npm.cmd</executable.npm>
      </properties>
    </profile>
    <profile>
      <id>build-war-properties-unix</id>
      <activation>
        <os>
          <family>unix</family>
        </os>
      </activation>
      <properties>
        <executable.npm>npm</executable.npm>
      </properties>
    </profile>
  </profiles>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>${maven-war-plugin.version}</version>
        <configuration>
          <failOnMissingWebXml>false</failOnMissingWebXml>
          <webResources>
            <resource>
              <directory>dist</directory>
              <targetPath>/</targetPath>
            </resource>
          </webResources>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>${maven-exec-plugin.version}</version>
        <executions>
          <execution>
            <id>npm install</id>
            <configuration>
              <workingDirectory>./src/</workingDirectory>
              <executable>${executable.npm}</executable>
              <arguments>
                <argument>install</argument>
              </arguments>
            </configuration>
            <phase>compile</phase>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
          <execution>
            <id>npm build</id>
            <configuration>
              <workingDirectory>./src</workingDirectory>
              <executable>${executable.npm}</executable>
              <arguments>
                <argument>run-script</argument>
                <argument>build</argument>
              </arguments>
            </configuration>
            <phase>compile</phase>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <!-- These folder and file must be manually created after application generation -->
          <descriptor>src/assembly/bin.xml</descriptor>
          <finalName>${project.name}-${project.version}</finalName>
          <appendAssemblyId>false</appendAssemblyId>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
          <filesets>
            <fileset>
              <directory>dist</directory>
              <includes>
                <include>**/*</include>
              </includes>
              <followSymlinks>false</followSymlinks>
            </fileset>
          </filesets>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
