<?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>

    <artifactId>flow-component-base</artifactId>
    <version>1.3.0</version>
    <packaging>pom</packaging>
    <name>Flow component base</name>
    <description>Parent pom for individual component modules</description>

    <parent>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin-parent</artifactId>
        <version>2.0.1</version>
    </parent>

    <properties>
        <!-- Should be overridden in child modules -->
        <flow.version>1.3.0</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>

        <!-- 9.4.X version is causing component builds fail on cannot connect 
            to server -->
        <jetty.version>9.3.24.v20180605</jetty.version>
        <maven.failsafe.plugin.version>2.20</maven.failsafe.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>

        <!-- OSGi support -->
        <osgi.bundle.import.package>*</osgi.bundle.import.package>
        <osgi.bundle.export.package>com.vaadin.flow.component.*;-noimport:=true</osgi.bundle.export.package>
        <osgi.bundle.required.execution.environment>JavaSE-1.8</osgi.bundle.required.execution.environment>
        <osgi.bundle.license>http://www.apache.org/licenses/LICENSE-2.0</osgi.bundle.license>
        <osgi.bundle.name>${project.artifactId}</osgi.bundle.name>
        <osgi.bundle.symbolic.name>${project.groupId}.flow.component.${component.package.name}</osgi.bundle.symbolic.name>
        <osgi.bundle.package.private></osgi.bundle.package.private>
        <osgi.bundle.bundle.activator></osgi.bundle.bundle.activator>
        <osgi.bundle.description></osgi.bundle.description>
    </properties>

    <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>vaadin-prereleases</id>
            <url>https://maven.vaadin.com/vaadin-prereleases</url>
        </repository>
        <repository>
            <id>vaadin-snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
        </repository>
    </repositories>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.0.1</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <phase>package</phase>
                            <goals>
                                <goal>jar-no-fork</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>2.10.4</version>
                    <executions>
                        <execution>
                            <id>attach-javadocs</id>
                            <phase>package</phase>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <quiet>true</quiet>
                        <additionalparam>-Xdoclint:none</additionalparam>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <version>4.1.0</version>
                    <extensions>true</extensions>
                    <executions>
                        <execution>
                            <id>bundle-manifest</id>
                            <phase>process-classes</phase>
                            <goals>
                                <goal>manifest</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <exportScr>true</exportScr>
                        <instructions>
                            <Bundle-Name>${osgi.bundle.name}</Bundle-Name>
                            <Bundle-SymbolicName>${osgi.bundle.symbolic.name}</Bundle-SymbolicName>
                            <Import-Package>${osgi.bundle.import.package}</Import-Package>
                            <Export-Package>${osgi.bundle.export.package}</Export-Package>
                            <Private-Package>${osgi.bundle.package.private}</Private-Package>
                            <Bundle-Activator>${osgi.bundle.bundle.activator}</Bundle-Activator>
                            <Bundle-License>${osgi.bundle.license}</Bundle-License>
                            <Bundle-Description>${osgi.bundle.description}</Bundle-Description>
                            <_removeheaders>Built-By</_removeheaders>
                            <!-- Enable processing of OSGI DS component annotations -->
                            <_dsannotations>*</_dsannotations>
                            <!-- Enable processing of OSGI metatype annotations -->
                            <_metatypeannotations>*</_metatypeannotations>
                        </instructions>
                    </configuration>
                </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.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>
                            <webInfIncludeJarPattern>^((?!flow-server-production-mode).)*$</webInfIncludeJarPattern>
                            <resourceBases>
                                <resourceBase>${project.build.directory}/${project.build.finalName}</resourceBase>
                            </resourceBases>
                        </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>deploy-war</goal>
                            </goals>
                            <configuration>
                                <daemon>true</daemon>
                                <scanIntervalSeconds>0</scanIntervalSeconds>
                            </configuration>
                        </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>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>3.0.0</version>
                    <executions>
                        <execution>
                            <id>extract-component-name</id>
                            <goals>
                                <goal>regex-property</goal>
                            </goals>
                            <configuration>
                                <name>component.name</name>
                                <regex>vaadin-(\w+(-\w+)*)-flow</regex>
                                <value>${project.artifactId}</value>
                                <replacement>$1</replacement>
                                <failIfNoMatch>false</failIfNoMatch>
                            </configuration>
                        </execution>
                        <execution>
                            <id>extract-component-package-name</id>
                            <goals>
                                <goal>regex-property</goal>
                            </goals>
                            <configuration>
                                <name>component.package.name</name>
                                <regex>-</regex>
                                <value>${component.name}</value>
                                <replacement></replacement>
                                <failIfNoMatch>false</failIfNoMatch>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                <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>

                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>com.googlecode.maven-download-plugin</groupId>
                                        <artifactId>download-maven-plugin</artifactId>
                                        <versionRange>[1.3.0,)</versionRange>
                                        <goals>
                                            <goal>wget</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <execute>
                                            <runOnIncremental>false</runOnIncremental>
                                        </execute>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.webjars.bowergithub.polymer</groupId>
            <artifactId>polymer</artifactId>
            <version>2.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.webjars.bowergithub.webcomponents</groupId>
            <artifactId>webcomponentsjs</artifactId>
            <version>1.2.6</version>
        </dependency>
        <dependency>
            <groupId>org.webjars.bowergithub.webcomponents</groupId>
            <artifactId>shadycss</artifactId>
            <version>1.5.0-1</version>
        </dependency>
        <dependency>
            <groupId>org.webjars.bowergithub.vaadin</groupId>
            <artifactId>vaadin-element-mixin</artifactId>
            <!--  IMPORTANT NOTE: if you update this version check that 
               transitive dependencies (mvn dependency:tree) versions are 
               also the most recent ones: see below. At the moment these are
               two deps "vaadin-usage-statistics" and 
               "vaadin-development-mode-detector"  -->
            <version>2.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.webjars.bowergithub.vaadin</groupId>
            <artifactId>vaadin-usage-statistics</artifactId>
            <version>2.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.webjars.bowergithub.vaadin</groupId>
            <artifactId>vaadin-development-mode-detector</artifactId>
            <version>2.0.0</version>
        </dependency>
    </dependencies>

</project>
