<?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
  ~
  ~ https://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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.jboss.hal</groupId>
        <artifactId>hal-parent-with-gwt</artifactId>
        <version>3.2.3.Final</version>
        <relativePath>../parent-with-gwt/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>

    <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-flow</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.hal</groupId>
            <artifactId>hal-js</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>
        <dependency>
            <groupId>org.jboss.hal</groupId>
            <artifactId>hal-theme-${theme.name}</artifactId>
        </dependency>

        <!-- GWT -->
        <dependency>
            <groupId>org.jboss.gwt.elemento</groupId>
            <artifactId>elemento-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.gwt.elemento</groupId>
            <artifactId>elemento-widget</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.gwt.elemento</groupId>
            <artifactId>elemento-template-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.gwt.elemento</groupId>
            <artifactId>elemento-template-processor</artifactId>
            <scope>provided</scope>
        </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-elemental</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava-gwt</artifactId>
        </dependency>
        <dependency>
            <groupId>com.intendia.gwt.rxgwt</groupId>
            <artifactId>rxgwt</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>ru.finam</groupId>
            <artifactId>slf4j-gwt</artifactId>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>com.google.testing.compile</groupId>
            <artifactId>compile-testing</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/java</directory>
                <includes>
                    <include>**/*.java</include>
                </includes>
            </testResource>
            <testResource>
                <directory>src/test/resources</directory>
                <includes>
                    <include>**/*.java</include>
                    <include>**/*.mbui.xml</include>
                </includes>
            </testResource>
        </testResources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>src/main/resources/org/jboss/hal/public</directory>
                            <includes>
                                <include>*.ico</include>
                                <include>*.png</include>
                            </includes>
                        </fileset>
                        <fileset>
                            <directory>src/main/resources/org/jboss/hal/public/css</directory>
                        </fileset>
                        <fileset>
                            <directory>src/main/resources/org/jboss/hal/public/fonts</directory>
                        </fileset>
                        <fileset>
                            <directory>src/main/resources/org/jboss/hal/public/img</directory>
                        </fileset>
                        <fileset>
                            <directory>src/main/resources/org/jboss/hal/public/js</directory>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <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</id>
                        <goals>
                            <goal>npm</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.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/annotations</source>
                                <source>../ballroom/src/main/java</source>
                                <source>../config/src/main/java</source>
                                <source>../core/src/main/java</source>
                                <source>../db/src/main/java</source>
                                <source>../dmr/src/main/java</source>
                                <source>../flow/src/main/java</source>
                                <source>../js/src/main/java</source>
                                <source>../meta/src/main/java</source>
                                <source>../resources/src/main/java</source>
                                <source>../spi/src/main/java</source>
                                <source>../themes/${theme.name}/src/main/java</source>
                            </sources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>add-resources</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>add-resource</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>../resources/src/main/resources</directory>
                                </resource>
                                <resource>
                                    <directory>../themes/${theme.name}/src/main/resources</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </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>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>
                        <compilerArg>-generateJsInteropExports</compilerArg>
                        <compilerArg>-Xnamespace</compilerArg>
                        <compilerArg>NONE</compilerArg>
                        <compilerArg>-setProperty</compilerArg>
                        <compilerArg>gwt.logging.logLevel=${gwt.logLevel}</compilerArg>
                    </compilerArgs>
                    <devmodeArgs>
                        <devmodeArg>-startupUrl</devmodeArg>
                        <devmodeArg>hal/dev.html</devmodeArg>
                        <devmodeArg>-generateJsInteropExports</devmodeArg>
                        <devmodeArg>-bindAddress</devmodeArg>
                        <devmodeArg>${gwt.devmode.hostname}</devmodeArg>
                    </devmodeArgs>
                    <jvmArgs>
                        <jvmArg>-Xms1024m</jvmArg>
                        <jvmArg>-Xmx2048m</jvmArg>
                        <jvmArg>-Xss1024k</jvmArg>
                    </jvmArgs>
                    <draftCompile>${gwt.draftCompile}</draftCompile>
                    <failOnError>${gwt.failOnError}</failOnError>
                    <moduleName>org.jboss.hal.Console</moduleName>
                    <moduleShortName>hal</moduleShortName>
                    <moduleTemplate>${gwt.moduleTemplate}</moduleTemplate>
                    <optimize>${gwt.optimize}</optimize>
                    <style>${gwt.style}</style>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>esdoc</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>process-es6-documentation</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                                <configuration>
                                    <compilerArgs>
                                        <arg>-proc:only</arg>
                                        <arg>-processor</arg>
                                        <arg>org.jboss.hal.processor.EsDocProcessor</arg>
                                    </compilerArgs>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>grunt-esdoc</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>grunt</goal>
                                </goals>
                                <configuration>
                                    <arguments>esdoc</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>i18n</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>net.ltgt.gwt.maven</groupId>
                        <artifactId>gwt-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>generate-i18n-module</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>generate-module</goal>
                                </goals>
                                <configuration>
                                    <moduleTemplate>${project.basedir}/src/main/module-i18n.gwt.xml</moduleTemplate>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
