<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2014 Red Hat, Inc.
  ~
  ~ 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>
    <artifactId>rhq-metrics-parent</artifactId>
    <groupId>org.rhq.metrics</groupId>
    <version>0.2.6</version>
    <relativePath>../../pom.xml</relativePath>
  </parent>
  <artifactId>explorer</artifactId>
  <packaging>war</packaging>

  <name>metrics-explorer</name>

  <properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <build>
    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <configuration>
          <excludes>
            src/main/webapp/bower_components/**/*,
            src/main/webapp/node_modules/**/*,
            src/main/webapp/node/**/*,
          </excludes>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <failOnMissingWebXml>false</failOnMissingWebXml>
          <warSourceDirectory>${project.build.directory}/dist</warSourceDirectory>
          <packagingExcludes>WEB-INF/classes</packagingExcludes>
        </configuration>
      </plugin>

      <!-- Download node.js and related modules to install 3rd party frontend libraries -->
      <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>0.0.16</version>

        <configuration>
          <workingDirectory>${basedir}/src/main/webapp</workingDirectory>
        </configuration>

        <executions>
          <execution>
            <id>install node and npm</id>
            <goals>
              <goal>install-node-and-npm</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
              <nodeVersion>v0.10.33</nodeVersion>
              <npmVersion>1.4.28</npmVersion>
            </configuration>
          </execution>

          <execution>
            <id>npm install</id>
            <goals>
              <goal>npm</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
              <arguments>install</arguments>
            </configuration>
          </execution>

          <execution>
            <id>grunt build</id>
            <goals>
              <goal>grunt</goal>
            </goals>
            <phase>generate-sources</phase>

            <configuration>
              <arguments>build</arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>cleanAll</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <version>2.6.1</version>
            <configuration>
              <filesets>
                <fileset>
                  <directory>src/main/webapp/node_modules</directory>
                </fileset>
                <fileset>
                  <directory>src/main/webapp/bower_components</directory>
                </fileset>
                <fileset>
                  <directory>src/main/webapp/node</directory>
                </fileset>
              </filesets>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
