<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2022 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>io.quarkiverse.dashbuilder</groupId>
    <artifactId>quarkus-dashbuilder-parent</artifactId>
    <version>0.32.0</version>
  </parent>
  <artifactId>quarkus-dashbuilder-ui</artifactId>
  <name>Dashbuilder Quarkus Extension - UI</name>
  <description>Dashbuilder extension Web Bundle</description>
  <properties>
    <dashbuilder.unzip.dir>${project.build.directory}/dashbuilder</dashbuilder.unzip.dir>
    <dashbuilder.content.dir>${dashbuilder.unzip.dir}/${dashbuilder.package}/dist/</dashbuilder.content.dir>
  </properties>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-scm-plugin</artifactId>
        <version>2.0.1</version>
        <configuration>
          <connectionType>developerConnection</connectionType>
          <providerImplementations>
            <git>jgit</git>
          </providerImplementations>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.apache.maven.scm</groupId>
            <artifactId>maven-scm-provider-jgit</artifactId>
            <version>2.0.1</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>clone-samples</id>
            <phase>validate</phase>
            <goals>
              <goal>checkout</goal>
            </goals>
            <configuration>
              <developerConnectionUrl>scm:git:${samples.git.url}</developerConnectionUrl>
              <scmVersion>${version.dashbuilder.npm}</scmVersion>
              <scmVersionType>tag</scmVersionType>
              <checkoutDirectory>${project.build.directory}/kie-samples</checkoutDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.orienteer.jnpm</groupId>
        <artifactId>jnpm-maven-plugin</artifactId>
        <version>${version.org.orienteer.jnpm}</version>
        <executions>
          <execution>
            <goals>
              <goal>install</goal>
            </goals>
            <configuration>
              <outputDirectory>${dashbuilder.unzip.dir}</outputDirectory>
              <strategy>SIMPLE</strategy>
              <packages>
                <package>${dashbuilder.package}@~${version.dashbuilder.npm}</package>
              </packages>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-dashbuilder</id>
            <phase>validate</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${dashbuilder.content.dir}</outputDirectory>
              <resources>
                <resource>
                  <directory>src/${samples.src.dir}</directory>
                  <filtering>true</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-samples</id>
            <phase>initialize</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${dashbuilder.content.dir}/samples/</outputDirectory>
              <resources>
                <resource>
                  <directory>${project.build.directory}/kie-samples/samples/</directory>
                  <filtering>true</filtering>
                  <includes>
                    <!-- Dashbuilder Extension Samples -->
                    <include>dashbuilder-kitchensink/**/*.svg</include>
                    <include>dashbuilder-kitchensink/**/*.dash.yaml</include>
                    <include>products-dashboard/**/*.svg</include>
                    <include>products-dashboard/**/*.dash.yaml</include>
                    <!-- Micrometer (commented while issue with properties are resolved) 
                    <include>jvm-monitoring-micrometer/**/*.svg</include>
                    <include>jvm-monitoring-micrometer/**/*.dash.yaml</include>
                    <include>quarkus-micrometer-monitoring/**/*.svg</include>
                    <include>quarkus-micrometer-monitoring/**/*.dash.yaml</include>-->
                    <!-- Serverless Workflow 
                    <include>serverless-workflow-report/**/*.svg</include>
                    <include>serverless-workflow-report/**/*.dash.yaml</include>-->
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
