<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2015-2016 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.hal</groupId>
        <artifactId>hal-parent-with-dependencies</artifactId>
        <version>0.2.4</version>
        <relativePath>../parent-with-dependencies/pom.xml</relativePath>
    </parent>

    <artifactId>hal-app</artifactId>
    <name>HAL :: Application</name>
    <description>The HAL application containing the GWT entry point and the UI.</description>
    <packaging>gwt-app</packaging>

    <properties>
        <gulp-task>prod</gulp-task>
        <gwt.draftCompile>false</gwt.draftCompile>
        <gwt.failOnError>true</gwt.failOnError>
        <gwt.logLevel>INFO</gwt.logLevel>
        <gwt.optimize>9</gwt.optimize>
        <gwt.style>OBFUSCATED</gwt.style>
    </properties>

    <dependencies>
        <!-- HAL -->
        <dependency>
            <groupId>org.jboss.hal</groupId>
            <artifactId>hal-ballroom</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.hal</groupId>
            <artifactId>hal-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.hal</groupId>
            <artifactId>hal-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.hal</groupId>
            <artifactId>hal-dmr</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.hal</groupId>
            <artifactId>hal-processors</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.hal</groupId>
            <artifactId>hal-resources</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.hal</groupId>
            <artifactId>hal-spi</artifactId>
        </dependency>

        <!-- GWT -->
        <dependency>
            <groupId>org.jboss.gwt.flow</groupId>
            <artifactId>flow</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.gwt.elemento</groupId>
            <artifactId>elemento-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.gwt.elemento</groupId>
            <artifactId>elemento-gin</artifactId>
        </dependency>
        <dependency>
            <groupId>com.gwtplatform</groupId>
            <artifactId>gwtp-all</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-elemental</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava-gwt</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <classifier>sources</classifier>
        </dependency>
        <dependency>
            <groupId>ru.finam</groupId>
            <artifactId>slf4j-gwt</artifactId>
        </dependency>

        <!-- Misc -->
        <dependency>
            <groupId>org.jboss.gwt.circuit</groupId>
            <artifactId>circuit-processor</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <configuration>
                    <nodeVersion>${node.version}</nodeVersion>
                    <npmVersion>${npm.version}</npmVersion>
                </configuration>
                <executions>
                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>install</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>bower install</id>
                        <goals>
                            <goal>bower</goal>
                        </goals>
                        <configuration>
                            <arguments>install</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>gulp build</id>
                        <goals>
                            <goal>gulp</goal>
                        </goals>
                        <configuration>
                            <arguments>${gulp-task}</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.bsc.maven</groupId>
                <artifactId>maven-processor-plugin</artifactId>
                <!--
                    Execution order matters! Generate code for hal-app first, then generate the composite GIN module
                -->
                <executions>
                    <execution>
                        <id>generate-app-code</id>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <options>
                                <!-- Uncomment to get more messages from the annotation processors -->
                                <!--<debug>true</debug>-->
                            </options>
                            <defaultOutputDirectory>${project.build.directory}/generated-sources/apt-app
                            </defaultOutputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>generate-composite-gin</id>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <options>
                                <!-- Uncomment to get more messages from the annotation processors -->
                                <!--<debug>true</debug>-->
                            </options>
                            <defaultOutputDirectory>${project.build.directory}/generated-sources/apt-gin
                            </defaultOutputDirectory>
                            <additionalSourceDirectories>
                                <additionalSourceDirectory>${project.build.directory}/generated-sources/apt-app
                                </additionalSourceDirectory>
                                <additionalSourceDirectory>../config/src/main/java</additionalSourceDirectory>
                                <additionalSourceDirectory>../core/src/main/java</additionalSourceDirectory>
                                <additionalSourceDirectory>../dmr/src/main/java</additionalSourceDirectory>
                                <additionalSourceDirectory>../meta/src/main/java</additionalSourceDirectory>
                                <additionalSourceDirectory>../resources/src/main/java</additionalSourceDirectory>
                            </additionalSourceDirectories>
                            <processors>
                                <processor>org.jboss.hal.processor.GinModuleProcessor</processor>
                            </processors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <compilerArgument>-proc:none</compilerArgument>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-generated-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${project.build.directory}/generated-sources/apt-app</source>
                                <source>${project.build.directory}/generated-sources/apt-gin</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>net.ltgt.gwt.maven</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <configuration>
                    <compilerArgs>
                        <compilerArg>-gen</compilerArg>
                        <compilerArg>${project.build.directory}/generated-sources/gwt</compilerArg>
                   </compilerArgs>
                    <devmodeArgs>
                        <devmodeArg>-startupUrl</devmodeArg>
                        <devmodeArg>hal/dev.html</devmodeArg>
                        <devmodeArg>-incremental</devmodeArg>
                    </devmodeArgs>
                    <draftCompile>${gwt.draftCompile}</draftCompile>
                    <failOnError>${gwt.failOnError}</failOnError>
                    <logLevel>${gwt.logLevel}</logLevel>
                    <moduleName>${gwt.module}</moduleName>
                    <moduleShortName>${gwt.shortName}</moduleShortName>
                    <optimize>${gwt.optimize}</optimize>
                    <sourceLevel>1.8</sourceLevel>
                    <style>${gwt.style}</style>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <!--
                Activate this profile when running gwt:devmode from the command line
                to enable browser refresh after changing sources
            -->
            <id>dev</id>
            <properties>
                <gulp-task>dev</gulp-task>
                <gwt.draftCompile>true</gwt.draftCompile>
                <gwt.failOnError>false</gwt.failOnError>
                <gwt.logLevel>INFO</gwt.logLevel>
                <gwt.optimize>0</gwt.optimize>
                <gwt.style>PRETTY</gwt.style>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>add-dev-source</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>../ballroom/src/main/java</source>
                                        <source>../config/src/main/java</source>
                                        <source>../core/src/main/java</source>
                                        <source>../dmr/src/main/java</source>
                                        <source>../meta/src/main/java</source>
                                        <source>../resources/src/main/java</source>
                                        <source>../spi/src/main/java</source>
                                    </sources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
