<?xml version="1.0" encoding="UTF-8"?>
<!--

     Copyright 2022 Red Hat

     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-gwt-parent</artifactId>
        <version>3.7.9.Final</version>
        <relativePath>../gwt-parent/pom.xml</relativePath>
    </parent>

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

    <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.elemento</groupId>
            <artifactId>elemento-core</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.guava</groupId>
            <artifactId>guava-gwt</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.jsinterop</groupId>
            <artifactId>base</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>
            <!-- Ordered by artifactID -->
            <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>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>install-node-and-npm</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>${version.node}</nodeVersion>
                            <npmVersion>${version.npm}</npmVersion>
                            <skip>${skip.gwt}</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm-install</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>install</arguments>
                            <skip>${skip.gwt}</skip>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm-parcel</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run ${npm.script}</arguments>
                            <environmentVariables>
                                <THEME>${theme.name}</THEME>
                            </environmentVariables>
                            <skip>${skip.gwt}</skip>
                        </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>${gwt.moduleShortname}</moduleShortName>
                    <moduleTemplate>${gwt.moduleTemplate}</moduleTemplate>
                    <optimize>${gwt.optimize}</optimize>
                    <skipCompilation>${skip.gwt}</skipCompilation>
                    <style>${gwt.style}</style>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>resources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>src/assembly/resources.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                    <execution>
                        <id>webroot</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>src/assembly/webroot.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>.parcel-cache</directory>
                        </fileset>
                    </filesets>
                </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-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-gh-pages</id>
                        <phase>package</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>${project.artifactId}</artifactId>
                                    <version>${project.version}</version>
                                    <type>jar</type>
                                    <classifier>resources</classifier>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>${project.build.directory}/gh-pages</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>theme-eap</id>
            <properties>
                <gwt.moduleTemplate>${project.basedir}/src/main/module-i18n.gwt.xml</gwt.moduleTemplate>
            </properties>
            <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>
