<?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>

    <groupId>com.vaadin</groupId>
    <artifactId>flow-component-base</artifactId>
    <version>1.0.0.alpha5</version>
    <packaging>pom</packaging>
    <name>Flow component base</name>
    <description>Parent pom for individual component modules</description>

    <properties>
        <!-- Should be overridden in child modules -->
        <flow.version>1.0.0.alpha12</flow.version>

        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8
        </project.reporting.outputEncoding>

        <!-- Jetty 9.3.8/9.3.9 causes the build to fail with 'address already 
            in use' -->
        <jetty.version>9.3.7.v20160115</jetty.version>
        <maven.failsafe.plugin.version>2.20</maven.failsafe.plugin.version>
        <maven.deploy.plugin.version>2.8.2</maven.deploy.plugin.version>
        <maven.resources.plugin.version>3.0.2</maven.resources.plugin.version>
        <maven.deploy.plugin.version>2.8.2</maven.deploy.plugin.version>
        <driver.binary.downloader.maven.plugin.version>1.0.14
        </driver.binary.downloader.maven.plugin.version>
        <staging.server.id>vaadin-staging</staging.server.id>
        <staging.server.url>https://oss.sonatype.org/</staging.server.url>
    </properties>

    <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>

    <distributionManagement>
        <repository>
            <id>vaadin-staging</id>
            <name>Vaadin release staging repository</name>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
        <snapshotRepository>
            <id>vaadin-snapshots</id>
            <name>Vaadin snapshot repository</name>
            <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

    <repositories>
        <repository>
            <id>webjars</id>
            <url>https://dl.bintray.com/webjars/maven</url>
        </repository>
        <repository>
            <id>vaadin-webjars-bom</id>
            <url>https://maven.vaadin.com/vaadin-prereleases/</url>
        </repository>
    </repositories>

    <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>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${maven.failsafe.plugin.version}</version>
                <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>${maven.resources.plugin.version}</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>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.6.8</version>
                <extensions>true</extensions>
                <configuration>
                    <nexusUrl>${staging.server.url}</nexusUrl>
                    <serverId>${staging.server.id}</serverId>
                    <stagingProfileId>${staging.profile.id}</stagingProfileId>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.2</version>
                <configuration>
                    <finalName>${project.artifactId}</finalName>
                </configuration>
                <executions>
                    <execution>
                        <configuration>
                            <includes>
                                <include>**/*View.*</include>
                            </includes>
                            <classifier>demo</classifier>
                        </configuration>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>local-run</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </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>
