<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2020 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.dashbuilder</groupId>
    <artifactId>dashbuilder-shared</artifactId>
    <version>7.71.0.Final</version>
    <relativePath>../pom.xml</relativePath>
  </parent>

  <packaging>jar</packaging>
  <artifactId>dashbuilder-js</artifactId>
  <name>Dashbuilder JS</name>
  <description>Dashbuilder JS APIs and internal components for displaying data</description>

  <dependencies>
    <dependency>
      <groupId>org.uberfire</groupId>
      <artifactId>appformer-js-monaco</artifactId>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <properties>
    <!-- Comma separated internal components name -->
    <dashbuilder.internal.components.list>logo-provided,process-heatmap-provided,processes-heatmaps-provided,time-series-provided</dashbuilder.internal.components.list>
    <!-- Components base dir -->
    <dashbuilder.internal.components.root>web/dashbuilder/components</dashbuilder.internal.components.root>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.0.0</version>
        <executions>
          <execution>
            <phase>generate-resources</phase>
            <goals>
              <goal>write-project-properties</goal>
            </goals>
            <configuration>
              <outputFile>
                ${project.build.outputDirectory}/dashbuilder-components.properties</outputFile>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <configuration>
          <installDirectory>${project.build.directory}</installDirectory>
        </configuration>
        <executions>
          <execution>
            <id>install yarn</id>
            <goals>
              <goal>install-node-and-yarn</goal>
            </goals>
          </execution>
          <execution>
            <id>install node and npm</id>
            <phase>initialize</phase>
            <goals>
              <goal>install-node-and-npm</goal>
            </goals>
          </execution>
          <execution>
            <id>yarn run init</id>
            <goals>
              <goal>yarn</goal>
            </goals>
            <configuration>
              <arguments>run init</arguments>
            </configuration>
          </execution>
          <execution>
            <id>lock-treatment-tool execution</id>
            <phase>initialize</phase>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>exec @kie/lock-treatment-tool --</arguments>
            </configuration>
          </execution>
          <execution>
            <id>yarn run build:prod</id>
            <goals>
              <goal>yarn</goal>
            </goals>
            <configuration>
              <arguments>run build:prod</arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-logo-component</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>
                ${project.build.outputDirectory}/${dashbuilder.internal.components.root}/logo-provided
              </outputDirectory>
              <resources>
                <resource>
                  <directory>packages/logo-component/dist/</directory>
                  <filtering>false</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
          <execution>
            <id>copy-process-heatmap-component</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>

              <outputDirectory>
                ${project.build.outputDirectory}/${dashbuilder.internal.components.root}/process-heatmap-provided
              </outputDirectory>
              <resources>
                <resource>
                  <directory>packages/process-heatmap-component/dist/</directory>
                  <filtering>false</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
          <execution>
            <id>copy-processes-heatmaps-component</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>

              <outputDirectory>
                ${project.build.outputDirectory}/${dashbuilder.internal.components.root}/processes-heatmaps-provided
              </outputDirectory>
              <resources>
                <resource>
                  <directory>packages/processes-heatmaps-component/dist/</directory>
                  <filtering>false</filtering>
                </resource>
              </resources>
            </configuration>
          </execution> 
          <execution>
            <id>copy-time-series-component</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>

              <outputDirectory>
                ${project.build.outputDirectory}/${dashbuilder.internal.components.root}/time-series-provided
              </outputDirectory>
              <resources>
                <resource>
                  <directory>packages/time-series-component/dist/</directory>
                  <filtering>false</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>          
        </executions>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <versionRange>[1.8,)</versionRange>
                    <goals>
                      <goal>run</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore></ignore>
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>