<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-components-parent</artifactId>
        <version>1.0.0.alpha9</version>
    </parent>

    <groupId>com.vaadin</groupId>
    <artifactId>flow-component</artifactId>
    <version>1.0.0.alpha9</version>
    <packaging>pom</packaging>
    <name>Flow component</name>
    <description>Parent pom for individual component modules</description>

    <properties>
        <!-- Should be overridden in child modules -->
        <flow.version>${project.version}</flow.version>
    </properties>

    <repositories>
        <repository>
            <id>flow</id>
            <url>https://repo.vaadin.com/nexus/content/repositories/flow/</url>
        </repository>
        <repository>
            <id>flow-snapshots</id>
            <url>https://repo.vaadin.com/nexus/content/repositories/flow-snapshots/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-webjars-bom</artifactId>
                <type>pom</type>
                <scope>import</scope>
                <version>${flow.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>${jetty.version}</version>
                <configuration>
                    <httpConnector>
                        <port>9998</port>
                    </httpConnector>
                    <scanIntervalSeconds>-1</scanIntervalSeconds>
                    <stopPort>9999</stopPort>
                    <stopWait>5</stopWait>
                    <stopKey>foo</stopKey>
                    <!-- Use TestScope because the test classes are in the 
                        test package. -->
                    <useTestScope>true</useTestScope>
                    <webAppConfig>
                        <containerIncludeJarPattern>^$</containerIncludeJarPattern>
                    </webAppConfig>
                </configuration>
                <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>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <systemPropertyVariables>
                        <webdriver.chrome.driver>${webdriver.chrome.driver}</webdriver.chrome.driver>
                    </systemPropertyVariables>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.2</version>
                <executions>
                    <execution>
                        <id>copy-resources-for-demo-website</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/test-classes</outputDirectory>
                            <overwrite>true</overwrite>
                            <resources>
                                <resource>
                                    <directory>src/test/java</directory>
                                </resource>
                                <resource>
                                    <directory>src/main/webapp</directory>
                                    <targetPath>META-INF/resources</targetPath>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.googlecode.maven-download-plugin</groupId>
                <artifactId>download-maven-plugin</artifactId>
                <version>1.3.0</version>
                <executions>
                    <execution>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>wget</goal>
                        </goals>
                        <configuration>
                            <url>https://raw.githubusercontent.com/vaadin/flow/master/drivers.xml</url>
                            <outputFileName>drivers.xml</outputFileName>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>local-run</id>
            <activation>
                <property>
                    <name>!test.use.hub</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.lazerycode.selenium</groupId>
                        <artifactId>driver-binary-downloader-maven-plugin</artifactId>
                        <version>${driver.binary.downloader.maven.plugin.version}</version>
                        <configuration>
                            <onlyGetDriversForHostOperatingSystem>true</onlyGetDriversForHostOperatingSystem>
                            <rootStandaloneServerDirectory>${project.build.directory}/driver</rootStandaloneServerDirectory>
                            <downloadedZipFileDirectory>${project.build.directory}/driver_zips</downloadedZipFileDirectory>
                            <customRepositoryMap>${project.build.directory}/drivers.xml</customRepositoryMap>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>selenium</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
