<!--
 ! Licensed to the Apache Software Foundation (ASF) under one
 ! or more contributor license agreements.  See the NOTICE file
 ! distributed with this work for additional information
 ! regarding copyright ownership.  The ASF licenses this file
 ! to you 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">
  <parent>
    <artifactId>apache-asterixdb</artifactId>
    <groupId>org.apache.asterix</groupId>
    <version>0.9.4</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>asterix-dashboard</artifactId>

  <properties>
    <root.dir>${basedir}/..</root.dir>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.apache.hyracks</groupId>
      <artifactId>hyracks-http</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.asterix</groupId>
      <artifactId>asterix-common</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-all</artifactId>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.rat</groupId>
        <artifactId>apache-rat-plugin</artifactId>
        <executions>
          <execution>
            <id>default</id>
            <phase>validate</phase>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <licenses combine.children="append">
                <license
                    implementation="org.apache.rat.analysis.license.MITLicense"/>
              </licenses>
              <excludes combine.children="append">
                <exclude>src/main/resources/dashboard/static/*</exclude>
                <exclude>src/node/**</exclude>
              </excludes>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>1.6</version>
        <configuration>
          <nodeVersion>v10.3.0</nodeVersion>
          <npmVersion>6.1.0</npmVersion>
          <workingDirectory>target/dashboard</workingDirectory>
          <installDirectory>target/dashboard</installDirectory>
        </configuration>
        <executions>
          <execution>
            <id>install node and yarn</id>
            <goals>
              <goal>install-node-and-npm</goal>
            </goals>
            <phase>generate-resources</phase>
          </execution>
          <execution>
            <id>npm install</id>
            <phase>process-resources</phase>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>install --cache ${settings.localRepository}/.npm-cache --no-optional</arguments>
            </configuration>
          </execution>
          <execution>
            <id>npm run-script mavenbuild</id>
            <phase>compile</phase>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>run-script mavenbuild</arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-static</id>
            <phase>process-classes</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>
                ${basedir}/target/classes/dashboard/
              </outputDirectory>
              <resources>
                <resource>
                  <directory>${basedir}/target/dashboard/static/
                  </directory>
                </resource>
              </resources>
            </configuration>
          </execution>
          <execution>
            <id>copy-node</id>
            <phase>validate</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>
                ${basedir}/target/dashboard
              </outputDirectory>
              <resources>
                <resource>
                  <directory>${basedir}/src/node
                  </directory>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.hyracks</groupId>
        <artifactId>license-automation-plugin</artifactId>
        <executions>
          <execution>
            <phase>compile</phase>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <templateRootDir>${basedir}</templateRootDir>
          <outputDir>${project.build.directory}/classes/META-INF</outputDir>
          <generatedFiles>
            <generatedFile>
              <template>src/main/licenses/dashboard-license.ftl</template>
              <outputFile>LICENSE</outputFile>
            </generatedFile>
          </generatedFiles>
          <location>repo/</location>
          <timeoutSecs>10</timeoutSecs>
          <downloadDir>
            ${project.build.directory}/generated-resources/license
          </downloadDir>
          <excludedScopes>
            <excludedScope>test</excludedScope>
          </excludedScopes>
          <licenseDirectory>${basedir}/src/main/licenses/content</licenseDirectory>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
