<?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:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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.4.7</version>
        <relativePath>../parent-with-dependencies/pom.xml</relativePath>
    </parent>

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

    <properties>
        <grunt-task>dev</grunt-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>
        <theme.name>hal</theme.name>
    </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-meta</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.circuit</groupId>
            <artifactId>circuit-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.gwt.circuit</groupId>
            <artifactId>circuit-meta</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>
            <exclusions>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>servlet-api</artifactId>
                </exclusion>
            </exclusions>
        </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>ru.finam</groupId>
            <artifactId>slf4j-gwt</artifactId>
        </dependency>

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

        <!-- Test -->
        <dependency>
            <groupId>com.google.testing.compile</groupId>
            <artifactId>compile-testing</artifactId>
            <scope>test</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>grunt build</id>
                        <goals>
                            <goal>grunt</goal>
                        </goals>
                        <configuration>
                            <arguments>${grunt-task} --theme=${theme.name}</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>
                            <failOnError>false</failOnError>
                        </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>
                                <additionalSourceDirectory>../themes/${theme.name}/src/main/java
                                </additionalSourceDirectory>
                            </additionalSourceDirectories>
                            <processors>
                                <processor>org.jboss.hal.processor.GinModuleProcessor</processor>
                            </processors>
                        </configuration>
                    </execution>
                </executions>
            </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>
                                <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>
                                <source>../themes/eap/src/main/java</source>
                                <source>../themes/hal/src/main/java</source>
                                <source>../themes/wildfly/src/main/java</source>
                            </sources>
                        </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.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <classpathDependencyExcludes>
                        <classpathDependencyExcludes>com.google.guava:guava-gwt</classpathDependencyExcludes>
                    </classpathDependencyExcludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <id>mbui</id>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <classifier>mbui</classifier>
                            <includes>
                                <include>**/*.mbui.xml</include>
                            </includes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>resource-jar</id>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <classifier>resources</classifier>
                            <classesDirectory>${project.build.directory}/${project.build.finalName}/hal
                            </classesDirectory>
                        </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>
            <id>prod</id>
            <properties>
                <grunt-task>prod</grunt-task>
                <gwt.draftCompile>false</gwt.draftCompile>
                <gwt.failOnError>true</gwt.failOnError>
                <gwt.logLevel>INFO</gwt.logLevel>
                <!--
                    Do not optimize: It will wipe out code which actually must not be erased (like the
                    org.jboss.hal.ballroom.dragndrop.DragEvent.dataTransfer parameter of the onDrop event handler)
                    TODO Check if this is a bug in GWT or how much we can optimize until the code is removed.
                -->
                <gwt.optimize>0</gwt.optimize>
                <gwt.style>OBFUSCATED</gwt.style>
            </properties>
        </profile>
        <profile>
            <id>theme-eap</id>
            <properties>
                <theme.name>eap</theme.name>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.hal</groupId>
                    <artifactId>hal-theme-eap</artifactId>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>theme-hal</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <theme.name>hal</theme.name>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.hal</groupId>
                    <artifactId>hal-theme-hal</artifactId>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>theme-wildfly</id>
            <properties>
                <theme.name>wildfly</theme.name>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.hal</groupId>
                    <artifactId>hal-theme-wildfly</artifactId>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
</project>
