<?xml version="1.0" encoding="UTF-8"?>
<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>com.vaadin</groupId>
        <artifactId>flow-project</artifactId>
        <version>3.0.1</version>
    </parent>
    <artifactId>flow-client</artifactId>
    <name>Flow Client</name>
    <packaging>jar</packaging>

    <properties>
        <gwt.module>com.vaadin.ClientEngine</gwt.module>
        <gwt.module.output>${project.build.outputDirectory}/META-INF/resources/VAADIN/static/</gwt.module.output>
        <gwt.module.style>OBF</gwt.module.style>
        <gwt.sdm.bindAddress>0.0.0.0</gwt.sdm.bindAddress>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.google.gwt</groupId>
                <artifactId>gwt</artifactId>
                <version>${gwt.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>

        <!-- Project dependencies -->
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>flow-server</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-dev</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-elemental</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.ow2.asm</groupId>
            <artifactId>asm</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.platform</groupId>
            <artifactId>org.eclipse.core.resources</artifactId>
            <version>3.12.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <version>${osgi.core.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.cmpn</artifactId>
            <version>${osgi.compendium.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>${slf4j.version}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <resource>
                <directory>../flow-server/src/main/java</directory>
            </resource>
        </resources>

        <!-- Output classes directly into the webapp, so that IDEs and "mvn
            process-classes" update them in DevMode -->
        <!-- <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory> -->
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.2</version>
                <configuration>
                    <!-- Exclude all source files and classes so only the
                        compile result ends up in the JAR -->
                    <includes>
                        <include>com/vaadin/flow/client/osgi/*</include>
                        <include>META-INF/**</include>
                        <include>OSGI-INF/**</include>
                    </includes>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                        <index>false</index>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
                <configuration>
                    <excludes>
                        <exclude>**/Gwt*.java</exclude>
                    </excludes>
                    <enableAssertions>true</enableAssertions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- GWT Maven Plugin -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>${gwt.version}</version>

                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                            <goal>generateAsync</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>gwt-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <!-- Assertions should be disabled once we introduce
                        a separate production build -->
                    <enableAssertions>true</enableAssertions>
                    <failOnError>true</failOnError>
                    <gwtSdkFirstInClasspath></gwtSdkFirstInClasspath>
                    <persistentunitcache>false</persistentunitcache>
                    <webappDirectory>${gwt.module.output}</webappDirectory>
                    <launcherDir>${gwt.module.output}</launcherDir>
                    <compileReport>true</compileReport>
                    <bindAddress>${gwt.sdm.bindAddress}</bindAddress>
                    <modules>
                        <module>${gwt.module}</module>
                    </modules>
                    <webMode>true</webMode>
                    <style>${gwt.module.style}</style>
                    <htmlunit>FF38</htmlunit>
                    <testTimeOut>300</testTimeOut>
                    <extraJvmArgs>-Xmx512m -Dvaadin.enableDevServer=false</extraJvmArgs>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.github.ryanholdren</groupId>
                <artifactId>resourcecompressor</artifactId>
                <version>2017-06-24</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compress</goal>
                        </goals>
                        <phase>prepare-package</phase>
                        <configuration>
                            <directory>${gwt.module.output}/client/</directory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Include separate source dir for GWT tests -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.10</version>
                <executions>
                    <execution>
                        <id>add-gwt-test-sources-as-test-sources</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>add-test-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src/test-gwt/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.6.0</version>
                <executions>
                    <execution>
                        <id>npm-install</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>npm</executable>
                            <arguments>
                                <argument>install</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>typescript-compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>npm</executable>
                            <arguments>
                                <argument>run</argument>
                                <argument>compile</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>run-tests</id>
                        <phase>test</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>npm</executable>
                            <arguments>
                                <argument>test</argument>
                            </arguments>
                            <skip>${skipTests}</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>sdm</id>
            <properties>
                <gwt.module>com.vaadin.ClientEngineXSI</gwt.module>
            </properties>
        </profile>
    </profiles>
</project>
