<?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>vaadin-root</artifactId>
        <version>8.2-SNAPSHOT</version>
    </parent>
    <artifactId>vaadin-uitest</artifactId>
    <name>vaadin-uitest</name>
    <packaging>war</packaging>
    <properties>
        <skip.uitest.deployment>true</skip.uitest.deployment>
        <skip.uitest.failsafe>true</skip.uitest.failsafe>
        <!-- Don't care about coding style for tests -->
        <sonar.skip>true</sonar.skip>
    </properties>

    <url>https://vaadin.com/</url>
    <description>Vaadin UI tests</description>

    <repositories>
        <repository>
            <id>vaadin-addons</id>
            <url>http://maven.vaadin.com/vaadin-addons</url>
        </repository>
    </repositories>

    <prerequisites>
        <!-- phantomjs-maven-plugin required maven 3.1 or newer -->
        <maven>3.1</maven>
    </prerequisites>

    <dependencies>

        <!-- API DEPENDENCIES -->
        <dependency>
            <groupId>javax.portlet</groupId>
            <artifactId>portlet-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
        </dependency>

        <!-- jetty-servlets needed by ProxyTest, but not by jetty-runner -->
        <!-- Jetty before vaadin-* on the classpath to make Eclipse use the 
            right version -->
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-servlets</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty.websocket</groupId>
            <artifactId>websocket-server</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-webapp</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-util</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-proxy</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- LIBRARY DEPENDENCIES (compile time) -->
        <!-- Project modules -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>vaadin-server</artifactId>
            <version>${project.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>javax.servlet-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>vaadin-client</artifactId>
            <version>${project.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.validation</groupId>
                    <artifactId>javax.servlet-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-elemental</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
        </dependency>

        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>vaadin-client-compiled</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>vaadin-themes</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>vaadin-push</artifactId>
            <version>${project.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.validation</groupId>
                    <artifactId>javax.servlet-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Vaadin 7 components -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>vaadin-compatibility-client-compiled</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>vaadin-compatibility-server</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>vaadin-compatibility-themes</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>vaadin-compatibility-client</artifactId>
            <version>${project.version}</version>
        </dependency>
        <!-- For compiling TestingWidgetSet -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>vaadin-client-compiler</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Servlet API -->
        <dependency>
            <!-- Jetty requires 3.1.0 -->
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.jcraft</groupId>
            <artifactId>jsch</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <!-- Mainly for SQLContainer tests -->
        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
        </dependency>
        <!-- This should be removed once tests have been updated to use lang3 -->
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
        </dependency>

        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-sass-compiler</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jgit</groupId>
            <artifactId>org.eclipse.jgit</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.httpcomponents</groupId>
                    <artifactId>httpclient</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-testbench-api</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/themes</directory>
                <excludes>
                    <exclude>**/*.scss</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>


        <plugins>
            <plugin>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-maven-plugin</artifactId>
                <configuration>
                    <warSourceDirectory>src/main/themes</warSourceDirectory>
                    <webappDirectory>${project.build.outputDirectory}/VAADIN/widgetsets</webappDirectory>
                    <persistentunitcachedir>${project.build.directory}/gwt-unitCache</persistentunitcachedir>
                    <checkAssertions>true</checkAssertions>
                    <extraJvmArgs>-Xmx1G</extraJvmArgs>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compile-theme</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.github.klieber</groupId>
                <artifactId>phantomjs-maven-plugin</artifactId>
                <configuration>
                    <skip>${skip.uitest.failsafe}</skip>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>install</goal>
                        </goals>
                        <configuration>
                            <version>${phantomjs.version}</version>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>${jetty.version}</version>
                <configuration>
                    <httpConnector>
                        <port>8888</port>
                    </httpConnector>
                    <scanIntervalSeconds>-1</scanIntervalSeconds>
                    <stopPort>8889</stopPort>
                    <stopWait>5</stopWait>
                    <stopKey>foo</stopKey>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-install-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <configuration>
                    <skip>${skip.uitest.deployment}</skip>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <skip>${skip.uitest.failsafe}</skip>
                    <systemPropertyVariables>
                        <!-- Static path for screenshots pointing to submodule -->
                        <com.vaadin.testbench.screenshot.directory>${project.parent.basedir}/tests/screenshots</com.vaadin.testbench.screenshot.directory>

                        <!-- Optional properties for the test build -->
                        <vaadin.testbench.developer.license>${vaadin.testbench.developer.license}</vaadin.testbench.developer.license>
                        <com.vaadin.testbench.max.retries>${com.vaadin.testbench.max.retries}</com.vaadin.testbench.max.retries>
                        <browsers.include>${browsers.include}</browsers.include>
                        <browsers.exclude>${browsers.exclude}</browsers.exclude>
                        <categories.include>${categories.include}</categories.include>
                        <categories.exclude>${categories.exclude}</categories.exclude>
                        <useLocalWebDriver>${useLocalWebDriver}</useLocalWebDriver>
                        <!-- PhantomJS binary downloaded by phantomjs-maven-plugin -->
<!--                        <phantomjs.binary.path>${phantomjs.binary}</phantomjs.binary.path> -->
                    </systemPropertyVariables>
                    <includes>
                        <include>**/AllTB3Tests.java</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>animal-sniffer-maven-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>run-development-server</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>java</executable>
                            <arguments>
                                <argument>-ea</argument>
                                <argument>-classpath</argument>
                                <classpath/>
                                <argument>com.vaadin.launcher.DevelopmentServerLauncher</argument>
                            </arguments>
                            <classpathScope>test</classpathScope>
                        </configuration>
                    </execution>
                    <execution>
                        <id>debug-development-server</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>java</executable>
                            <arguments>
                                <argument>-ea</argument>
                                <argument>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005</argument>
                                <argument>-classpath</argument>
                                <classpath/>
                                <argument>com.vaadin.launcher.DevelopmentServerLauncher</argument>
                            </arguments>
                            <classpathScope>test</classpathScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <configuration>
                        <skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <configuration>
                        <skip>true</skip>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <!-- Profile used to deploy the uitest war for testing -->
            <id>dev-build</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <skip.uitest.deployment>false</skip.uitest.deployment>
            </properties>
        </profile>
        <profile>
            <id>test</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <skip.uitest.failsafe>false</skip.uitest.failsafe>
            </properties>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.eclipse.jetty</groupId>
                            <artifactId>jetty-maven-plugin</artifactId>

                            <executions>
                                <!-- start and stop jetty (running our app) 
                                    when running integration tests -->
                                <execution>
                                    <id>start-jetty</id>
                                    <phase>pre-integration-test</phase>
                                    <goals>
                                        <goal>start</goal>
                                    </goals>
                                </execution>
                                <execution>
                                    <id>stop-jetty</id>
                                    <phase>post-integration-test</phase>
                                    <goals>
                                        <goal>stop</goal>
                                    </goals>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>

        </profile>
        <profile>
            <id>measurements</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <skipTests>false</skipTests>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <groups>com.vaadin.testcategory.MeasurementTest</groups>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>

</project>