<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2019 ABSA Group Limited
  ~
  ~ 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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>za.co.absa.spline</groupId>
    <artifactId>parent</artifactId>
    <relativePath>../parent/pom.xml</relativePath>
    <version>0.4.2</version>
  </parent>

  <artifactId>client-ui</artifactId>
  <name>${project.artifactId}</name>

  <dependencies>
    <dependency>
      <groupId>za.co.absa.spline</groupId>
      <artifactId>consumer-rest-core</artifactId>
      <version>${project.version}</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>gen-swagger-json</id>
            <phase>process-classes</phase>
            <goals>
              <goal>java</goal>
            </goals>
            <configuration>
              <includePluginDependencies>true</includePluginDependencies>
              <executableDependency>
                <groupId>za.co.absa.spline</groupId>
                <artifactId>rest-api-doc-generator</artifactId>
              </executableDependency>
              <mainClass>za.co.absa.spline.swagger.SwaggerDocGenCLI</mainClass>
              <arguments>
                <argument>-o</argument>
                <argument>${project.basedir}/src/app/generated/swagger.json</argument>
                <argument>za.co.absa.spline.consumer.rest.ConsumerRESTConfig</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>za.co.absa.spline</groupId>
            <artifactId>rest-api-doc-generator</artifactId>
            <version>${project.version}</version>
          </dependency>
        </dependencies>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.8</version>
        <executions>
          <execution>
            <phase>prepare-package</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <exec executable="cmd" osfamily="windows" failonerror="true">
                  <env key="SPLINE_VERSION" value="${project.version}" />
                  <arg line="/c build.cmd" />
                </exec>
                <exec dir="." executable="bash" osfamily="unix" failonerror="true">
                  <env key="SPLINE_VERSION" value="${project.version}" />
                  <arg line="build.sh" />
                </exec>

                <echo message="Build Spline Webjar" />
                <copy todir="${project.build.outputDirectory}/META-INF/resources/webjars/spline/${project.version}">
                  <fileset dir="${project.basedir}/dist/ui2" />
                </copy>
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>license-check</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.rat</groupId>
            <artifactId>apache-rat-plugin</artifactId>
            <configuration>
              <excludes combine.children="append">
                <exclude>dist/**</exclude>
                <exclude>node_modules/**</exclude>
                <exclude>.editorconfig</exclude>
                <exclude>src/browserslist</exclude>
                <exclude>src/app/generated/**</exclude>
              </excludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
