<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2019 Red Hat, Inc. and/or its affiliates.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.optaweb.employeerostering</groupId>
    <artifactId>employee-rostering</artifactId>
    <version>7.30.0.Final</version>
  </parent>

  <artifactId>employee-rostering-frontend</artifactId>
  <name>Employee Rostering as a Service React Frontend</name>
  <description>React frontend for Employee Rostering as a Service</description>

  <properties>
    <frontend-maven-plugin.version>1.7.5</frontend-maven-plugin.version>
    <node.version>v8.12.0</node.version>
    <npm.version>6.9.0</npm.version>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>${frontend-maven-plugin.version}</version>
        <executions>
          <execution>
            <id>install node and npm</id>
            <phase>initialize</phase>
            <goals>
              <goal>install-node-and-npm</goal>
            </goals>
            <configuration>
              <nodeVersion>${node.version}</nodeVersion>
              <npmVersion>${npm.version}</npmVersion>
            </configuration>
          </execution>
          <execution>
            <id>npm install lock-treatment-tool and run-node</id>
            <phase>initialize</phase>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>install lock-treatment-tool --global-style --no-package-lock --no-save</arguments>
            </configuration>
          </execution>
          <execution>
            <id>lock-treatment-tool execution</id>
            <phase>compile</phase>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>run env -- locktt</arguments>
            </configuration>
          </execution>
          <execution>
            <id>npm install</id>
            <phase>compile</phase>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>install</arguments>
            </configuration>
          </execution>
          <execution>
            <id>npm typecheck</id>
            <phase>compile</phase>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>run typecheck</arguments>
            </configuration>
          </execution>
          <execution>
            <id>npm run lint</id>
            <phase>compile</phase>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>run lint</arguments>
            </configuration>
          </execution>
          <execution>
            <id>npm test</id>
            <phase>test</phase>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>run coverage</arguments>
            </configuration>
          </execution>
          <execution>
            <id>npm run build</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>run build</arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.github.ngeor</groupId>
        <artifactId>yak4j-json-yaml-converter-maven-plugin</artifactId>
        <version>0.0.4</version>
        <executions>
          <execution>
            <id>yaml2json</id>
            <goals>
              <goal>yaml2json</goal>
            </goals>
            <configuration>
              <sourceDirectory>translations</sourceDirectory>
              <includes>
                <include>**/*.yaml</include>
              </includes>
              <outputDirectory>public/assets/locales</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>position-react-build</id>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <phase>prepare-package</phase>
            <configuration>
              <outputDirectory>${project.build.outputDirectory}/static</outputDirectory>
              <resources>
                <resource>
                  <directory>build</directory>
                  <filtering>false</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <descriptors>
            <descriptor>assembly/sources.xml</descriptor>
          </descriptors>
          <appendAssemblyId>true</appendAssemblyId>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>sonar</id>
      <properties>
        <sonar.sources>src</sonar.sources>
        <sonar.test.inclusions>**/*test.ts,**/*test.tsx</sonar.test.inclusions>
        <sonar.typescript.lcov.reportPaths>coverage/lcov.info</sonar.typescript.lcov.reportPaths>
      </properties>
    </profile>
  </profiles>

</project>
