<?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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <artifactId>graphhopper-web-bundle</artifactId>
    <packaging>jar</packaging>
    <version>7.0-testgithub6</version>
    <properties>
        <graphhopper-maps.version>0.0.0-eb74bfd8de664e229ee2980dcbb99e83aa8287ce</graphhopper-maps.version>
    </properties>
    <name>GraphHopper Dropwizard Bundle</name>
    <description>Use the GraphHopper routing engine as a web-service</description>

    <parent>
        <groupId>com.graphhopper</groupId>
        <artifactId>graphhopper-parent</artifactId>
        <version>7.0-testgithub6</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>com.graphhopper</groupId>
            <artifactId>graphhopper-web-api</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <dependency>
            <groupId>com.graphhopper</groupId>
            <artifactId>graphhopper-core</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <dependency>
            <groupId>com.graphhopper</groupId>
            <artifactId>graphhopper-reader-gtfs</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <dependency>
            <groupId>com.graphhopper</groupId>
            <artifactId>graphhopper-map-matching</artifactId>
            <version>${project.parent.version}</version>
        </dependency>

        <!-- required for JDK9 -->
        <dependency>
            <groupId>javax.xml.ws</groupId>
            <artifactId>jaxws-api</artifactId>
            <version>2.3.1</version>
        </dependency>
        <!-- required for dropwizard -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-core</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-client</artifactId>
        </dependency>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-testing</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.locationtech.jts</groupId>
            <artifactId>jts-core</artifactId>
            <version>1.19.0</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.jaxrs</groupId>
            <artifactId>jackson-jaxrs-xml-provider</artifactId>
        </dependency>

        <!-- Pt and/or map-matching and/or isochrone web client dependencies-->
        <dependency>
            <groupId>org.webjars.npm</groupId>
            <artifactId>react</artifactId>
            <version>16.10.2</version>
        </dependency>
        <dependency>
            <groupId>org.webjars.npm</groupId>
            <artifactId>react-dom</artifactId>
            <version>16.10.2</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>leaflet</artifactId>
            <version>1.5.1</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>momentjs</artifactId>
            <version>2.24.0</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.webjars.npm</groupId>
            <artifactId>mapbox-gl</artifactId>
            <!-- this was the last mapbox release with an open license, the license was changed for 2.0+ -->
            <version>1.13.0</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>vue</artifactId>
            <version>2.6.12</version>
        </dependency>
        <dependency>
            <groupId>org.webjars.npm</groupId>
            <artifactId>papaparse</artifactId>
            <version>5.2.0</version>
        </dependency>

        <!-- for integration tests of service -->
        <dependency>
            <groupId>com.graphhopper</groupId>
            <artifactId>directions-api-client-hc</artifactId>
            <version>${project.parent.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.12.1</version>
                <executions>
                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>v16.17.0</nodeVersion>
                            <npmVersion>8.15.0</npmVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>download graphhopper maps</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <!--suppress UnresolvedMavenProperty (IntelliJ shows an error otherwise...)-->
                            <arguments>
                                pack --pack-destination=${basedir}/target
                                @graphhopper/graphhopper-maps-bundle@${graphhopper-maps.version}
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <!-- this is needed because we want to download the maps bundle to the target folder -->
                        <id>create target directory</id>
                        <phase>initialize</phase>
                        <configuration>
                            <tasks>
                                <mkdir dir="${basedir}/target"/>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>unzip maps bundle</id>
                        <phase>process-resources</phase>
                        <configuration>
                            <tasks>
                                <untar compression="gzip"
                                       src="${basedir}/target/graphhopper-graphhopper-maps-bundle-${graphhopper-maps.version}.tgz"
                                       dest="${basedir}/target/classes/com/graphhopper/maps">
                                    <patternset>
                                        <include name="package/dist/**"/>
                                        <exclude name="package/dist/config.js"/>
                                    </patternset>
                                    <mapper type="regexp" from="package\/dist\/(.*)" to="\1"/>
                                </untar>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>


