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

  <parent>
    <artifactId>zeppelin</artifactId>
    <groupId>org.apache.zeppelin</groupId>
    <version>0.7.0</version>
    <relativePath>..</relativePath>
  </parent>

  <groupId>org.apache.zeppelin</groupId>
  <artifactId>zeppelin-web</artifactId>
  <packaging>war</packaging>
  <version>0.7.0</version>
  <name>Zeppelin: web Application</name>

  <!-- See https://github.com/eirslett/frontend-maven-plugin/issues/229 -->
  <prerequisites>
    <maven>3.1.0</maven>
  </prerequisites>

  <properties>
    <node.version>v6.9.1</node.version>
    <yarn.version>v0.18.1</yarn.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <!--plugin versions-->
    <plugin.frontned.version>1.3</plugin.frontned.version>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <warSourceDirectory>dist</warSourceDirectory>
          <webXml>dist\WEB-INF\web.xml</webXml>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.rat</groupId>
        <artifactId>apache-rat-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>**/.idea/</exclude>
            <exclude>**/*.iml</exclude>
            <exclude>.git/</exclude>
            <exclude>.gitignore</exclude>
            <exclude>.babelrc</exclude>
            <exclude>.bowerrc</exclude>
            <exclude>.editorconfig</exclude>
            <exclude>.jscsrc</exclude>
            <exclude>.eslintrc</exclude>
            <exclude>.tmp/**</exclude>
            <exclude>**/.settings/*</exclude>
            <exclude>**/.classpath</exclude>
            <exclude>**/.project</exclude>
            <exclude>**/target/**</exclude>
            <exclude>node/**</exclude>
            <exclude>node_modules/**</exclude>
            <exclude>bower_components/**</exclude>
            <exclude>test/**</exclude>
            <exclude>dist/**</exclude>
            <exclude>src/.buildignore</exclude>
            <exclude>src/fonts/fontawesome*</exclude>
            <exclude>src/fonts/font-awesome*</exclude>
            <exclude>src/styles/font-awesome*</exclude>
            <exclude>src/fonts/Simple-Line*</exclude>
            <exclude>src/fonts/simple-line*</exclude>
            <exclude>src/fonts/patua-one*</exclude>
            <exclude>src/fonts/roboto*</exclude>
            <exclude>src/fonts/source-code-pro*</exclude>
            <exclude>src/fonts/google-fonts.css</exclude>
            <exclude>bower.json</exclude>
            <exclude>**/package.json</exclude>
            <exclude>**/.npmignore</exclude>
            <exclude>yarn.lock</exclude>
            <exclude>*.md</exclude>
          </excludes>
        </configuration>
      </plugin>

      <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>${plugin.frontned.version}</version>
        <executions>

          <execution>
            <id>install node and yarn</id>
            <goals>
              <goal>install-node-and-yarn</goal>
            </goals>
            <configuration>
              <nodeVersion>${node.version}</nodeVersion>
              <yarnVersion>${yarn.version}</yarnVersion>
            </configuration>
          </execution>

          <execution>
            <id>yarn install</id>
            <goals>
              <goal>yarn</goal>
            </goals>
            <configuration>
              <arguments>install --no-lockfile</arguments>
            </configuration>
          </execution>

          <execution>
            <id>yarn build</id>
            <goals>
              <goal>yarn</goal>
            </goals>
            <configuration>
              <arguments>run build</arguments>
            </configuration>
          </execution>

          <execution>
            <id>yarn test</id>
            <goals>
              <goal>yarn</goal>
            </goals>
            <phase>test</phase>
            <configuration>
              <arguments>run test</arguments>
            </configuration>
          </execution>

        </executions>
      </plugin>

      <!--
          Disabling test report generation as it forks the lifecycle
          and results in https://issues.apache.org/jira/browse/ZEPPELIN-69

          There is no better way to do it, as per
          http://jira.codehaus.org/browse/MCOBERTURA-154
      -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>cobertura</id>
            <phase>none</phase>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
      </plugin>

      <plugin>
        <!-- clean task will be executed by front-end-maven plugin -->
        <artifactId>maven-clean-plugin</artifactId>
        <configuration>
          <filesets>
            <fileset>
              <directory>bower_components</directory>
            </fileset>
            <fileset>
              <directory>node</directory>
            </fileset>
            <fileset>
              <directory>node_modules</directory>
            </fileset>
          </filesets>
        </configuration>
      </plugin>
    </plugins>
  </build>


</project>
