<?xml version="1.0" encoding="UTF-8"?>
<!--
  JBoss, Home of Professional Open Source
  Copyright Red Hat, Inc., and individual contributors

  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>org.jboss</groupId>
        <artifactId>jboss-parent</artifactId>
        <version>24</version>
    </parent>

    <groupId>org.aerogear.unifiedpush</groupId>
    <artifactId>admin-ui</artifactId>
    <version>2.2.0</version>
    <packaging>jar</packaging>
    <name>UnifiedPush Admin UI</name>
<repositories>
        <repository>
            <id>jboss-public-snapshot-repository-group</id>
            <url>https://repository.jboss.org/nexus/content/repositories/snapshots/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <releases>
                <enabled>false</enabled>
            </releases>
        </repository>
    </repositories>

    <scm>
        <connection>scm:git:git://github.com/aerogear/unifiedpush-admin-ui.git</connection>
        <developerConnection>scm:git:git@github.com:aerogear/unifiedpush-admin-ui.git</developerConnection>
        <url>https://github.com/aerogear/unifiedpush-admin-ui</url>
        <tag>2.2.0</tag>
    </scm>

    <build>

        <resources>
            <resource>
                <!-- no need to include the database modules -->
                <directory>dist/</directory>
                <targetPath>META-INF/resources/</targetPath>
            </resource>
        </resources>

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

                <configuration>
                    <workingDirectory>./</workingDirectory>
                </configuration>

                <executions>
                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <nodeVersion>v5.0.0</nodeVersion>
                            <npmVersion>3.3.6</npmVersion>
                        </configuration>
                    </execution>

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

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

                        <configuration>
                            <arguments>dist</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <tarLongFileMode>gnu</tarLongFileMode>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptors>
                        <descriptor>assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id> <!-- this is used for inheritance merges -->
                        <phase>package</phase> <!-- append to the install phase. -->
                        <goals>
                            <goal>single</goal> <!-- goals == mojos -->
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>./</directory>
                            <includes>
                                <include>dist/**</include>
                                <include>.tmp/**</include>
                                <include>.build-tmp/**</include>
                            </includes>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <!--
                Clears all cached Node/NPM/Bower artifacts makes completely fresh build

                usage: mvn clean install -Dfrontend.clean.force
            -->
            <id>frontend-forced-clean</id>
            <activation>
                <property>
                    <name>frontend.clean.force</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-clean-plugin</artifactId>
                        <version>2.5</version>
                        <configuration>
                            <filesets>
                                <fileset>
                                    <directory>./</directory>
                                    <includes>
                                        <include>dist/**</include>
                                        <include>.tmp/**</include>
                                        <include>.build-tmp/**</include>
                                        <include>node/**</include>
                                        <include>node_modules/**</include>
                                        <include>node_tmp/**</include>
                                        <include>app/bower_components/**</include>
                                    </includes>
                                    <followSymlinks>false</followSymlinks>
                                </fileset>
                            </filesets>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
