<?xml version="1.0" encoding="UTF-8"?>

<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<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">
    <parent>
        <artifactId>hudi</artifactId>
        <groupId>org.apache.hudi</groupId>
        <version>0.12.0-SNAPSHOT</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>hudi-timeline-server-bundle</artifactId>
    <packaging>jar</packaging>

    <dependencies>
        <!-- Hoodie -->
        <dependency>
            <groupId>org.apache.hudi</groupId>
            <artifactId>hudi-common</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.hudi</groupId>
            <artifactId>hudi-timeline-service</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
        </dependency>

        <!-- Fasterxml -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>

        <!-- Httpcomponents -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>fluent-hc</artifactId>
        </dependency>

        <dependency>
            <groupId>io.javalin</groupId>
            <artifactId>javalin</artifactId>
            <version>2.8.0</version>
        </dependency>

        <dependency>
            <groupId>com.beust</groupId>
            <artifactId>jcommander</artifactId>
        </dependency>

        <dependency>
            <groupId>org.rocksdb</groupId>
            <artifactId>rocksdbjni</artifactId>
        </dependency>

        <!-- Hadoop -->
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-hdfs</artifactId>
            <!-- Need these exclusions to make sure JavaSparkContext can be setup. https://issues.apache.org/jira/browse/SPARK-1693 -->
            <exclusions>
                <exclusion>
                    <groupId>org.mortbay.jetty</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.servlet.jsp</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-common</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.mortbay.jetty</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.servlet.jsp</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-client</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>${maven-shade-plugin.version}</version>
            <configuration>
                <createDependencyReducedPom>true</createDependencyReducedPom>
                <filters>
                    <filter>
                        <artifact>*:*</artifact>
                        <excludes>
                            <exclude>META-INF/*.SF</exclude>
                            <exclude>META-INF/*.DSA</exclude>
                            <exclude>META-INF/*.RSA</exclude>
                            <exclude>META-INF/services/javax.*</exclude>
                            <exclude>**/*.proto</exclude>
                            <exclude>hbase-webapps/**</exclude>
                        </excludes>
                    </filter>
                </filters>
                <artifactSet>
                  <includes>
                      <!-- 
                         Include hudi-timeline-server with javalin dependencies. 
                         hadoop deps are to be provided at runtime. see run_server.sh 
                      -->
                      <include>org.apache.hudi:hudi-common</include>
                      <include>org.apache.hudi:hudi-timeline-service</include>
                      <include>org.apache.httpcomponents:httpclient</include>
                      <include>org.apache.httpcomponents:httpcore</include>
                      <include>org.mortbay.jetty:jetty</include>
                      <include>org.mortbay.jetty:jetty-util</include>
                      <include>org.apache.httpcomponents:fluent-hc</include>
                      <include>io.javalin:javalin</include>
                      <include>org.jetbrains.kotlin:kotlin-stdlib-jdk8</include>
                      <include>org.jetbrains.kotlin:kotlin-stdlib</include>
                      <include>org.jetbrains.kotlin:kotlin-stdlib-common</include>
                      <include>org.jetbrains:annotations</include>
                      <include>org.jetbrains.kotlin:kotlin-stdlib-jdk7</include>
                      <include>org.eclipse.jetty:jetty-server</include>
                      <include>org.eclipse.jetty:jetty-http</include>
                      <include>org.eclipse.jetty:jetty-util</include>
                      <include>org.eclipse.jetty:jetty-io</include>
                      <include>org.eclipse.jetty:jetty-webapp</include>
                      <include>org.eclipse.jetty:jetty-xml</include>
                      <include>org.eclipse.jetty:jetty-servlet</include>
                      <include>org.eclipse.jetty:jetty-security</include>
                      <include>org.eclipse.jetty.websocket:websocket-server</include>
                      <include>org.eclipse.jetty.websocket:websocket-common</include>
                      <include>org.eclipse.jetty.websocket:websocket-api</include>
                      <include>org.eclipse.jetty.websocket:websocket-client</include>
                      <include>org.eclipse.jetty:jetty-client</include>
                      <include>org.eclipse.jetty.websocket:websocket-servlet</include>
                      <include>com.beust:jcommander</include>
                      <include>org.rocksdb:rocksdbjni</include>
                      <include>org.codehaus.jackson:jackson-core-asl</include>
                      <include>org.codehaus.jackson:jackson-mapper-asl</include>
                      <include>com.fasterxml.jackson.core:jackson-annotations</include>
                      <include>com.fasterxml.jackson.core:jackson-core</include>
                      <include>com.fasterxml.jackson.core:jackson-databind</include>
                      <include>org.apache.hbase:hbase-common</include>
                      <include>org.apache.hbase:hbase-client</include>
                      <include>org.apache.hbase:hbase-hadoop-compat</include>
                      <include>org.apache.hbase:hbase-hadoop2-compat</include>
                      <include>org.apache.hbase:hbase-metrics</include>
                      <include>org.apache.hbase:hbase-metrics-api</include>
                      <include>org.apache.hbase:hbase-protocol</include>
                      <include>org.apache.hbase:hbase-protocol-shaded</include>
                      <include>org.apache.hbase:hbase-server</include>
                      <include>org.apache.hbase.thirdparty:hbase-shaded-miscellaneous</include>
                      <include>org.apache.hbase.thirdparty:hbase-shaded-netty</include>
                      <include>org.apache.hbase.thirdparty:hbase-shaded-protobuf</include>
                      <include>org.apache.htrace:htrace-core4</include>
                      <include>com.esotericsoftware:kryo-shaded</include>
                      <include>com.esotericsoftware:minlog</include>
                      <include>commons-io:commons-io</include>
                      <include>log4j:log4j</include>
                      <include>org.objenesis:objenesis</include>
                  </includes>
                </artifactSet>
                <relocations>
                    <relocation>
                        <pattern>org.apache.commons.io.</pattern>
                        <shadedPattern>org.apache.hudi.org.apache.commons.io.</shadedPattern>
                    </relocation>
                    <relocation>
                        <pattern>org.apache.hadoop.hbase.</pattern>
                        <shadedPattern>org.apache.hudi.org.apache.hadoop.hbase.</shadedPattern>
                        <excludes>
                            <exclude>org.apache.hadoop.hbase.KeyValue$KeyComparator</exclude>
                        </excludes>
                    </relocation>
                    <relocation>
                        <pattern>org.apache.hbase.</pattern>
                        <shadedPattern>org.apache.hudi.org.apache.hbase.</shadedPattern>
                    </relocation>
                    <relocation>
                        <pattern>org.apache.htrace.</pattern>
                        <shadedPattern>org.apache.hudi.org.apache.htrace.</shadedPattern>
                    </relocation>
                    <!-- The classes below in org.apache.hadoop.metrics2 package come from
                hbase-hadoop-compat and hbase-hadoop2-compat, which have to be shaded one by one,
                instead of shading all classes under org.apache.hadoop.metrics2 including ones
                from hadoop. -->
                    <relocation>
                        <pattern>org.apache.hadoop.metrics2.MetricHistogram</pattern>
                        <shadedPattern>org.apache.hudi.org.apache.hadoop.metrics2.MetricHistogram
                        </shadedPattern>
                    </relocation>
                    <relocation>
                        <pattern>org.apache.hadoop.metrics2.MetricsExecutor</pattern>
                        <shadedPattern>org.apache.hudi.org.apache.hadoop.metrics2.MetricsExecutor
                        </shadedPattern>
                    </relocation>
                    <relocation>
                        <pattern>org.apache.hadoop.metrics2.impl.JmxCacheBuster</pattern>
                        <shadedPattern>org.apache.hudi.org.apache.hadoop.metrics2.impl.JmxCacheBuster</shadedPattern>
                    </relocation>
                    <relocation>
                        <pattern>org.apache.hadoop.metrics2.lib.DefaultMetricsSystemHelper</pattern>
                        <shadedPattern>org.apache.hudi.org.apache.hadoop.metrics2.lib.DefaultMetricsSystemHelper
                        </shadedPattern>
                    </relocation>
                    <relocation>
                        <pattern>org.apache.hadoop.metrics2.lib.DynamicMetricsRegistry</pattern>
                        <shadedPattern>org.apache.hudi.org.apache.hadoop.metrics2.lib.DynamicMetricsRegistry
                        </shadedPattern>
                    </relocation>
                    <relocation>
                        <pattern>org.apache.hadoop.metrics2.lib.MetricsExecutorImpl</pattern>
                        <shadedPattern>org.apache.hudi.org.apache.hadoop.metrics2.lib.MetricsExecutorImpl
                        </shadedPattern>
                    </relocation>
                    <relocation>
                        <pattern>org.apache.hadoop.metrics2.lib.MutableFastCounter</pattern>
                        <shadedPattern>org.apache.hudi.org.apache.hadoop.metrics2.lib.MutableFastCounter
                        </shadedPattern>
                    </relocation>
                    <relocation>
                        <pattern>org.apache.hadoop.metrics2.lib.MutableHistogram</pattern>
                        <shadedPattern>org.apache.hudi.org.apache.hadoop.metrics2.lib.MutableHistogram
                        </shadedPattern>
                    </relocation>
                    <relocation>
                        <pattern>org.apache.hadoop.metrics2.lib.MutableRangeHistogram</pattern>
                        <shadedPattern>org.apache.hudi.org.apache.hadoop.metrics2.lib.MutableRangeHistogram
                        </shadedPattern>
                    </relocation>
                    <relocation>
                        <pattern>org.apache.hadoop.metrics2.lib.MutableSizeHistogram</pattern>
                        <shadedPattern>org.apache.hudi.org.apache.hadoop.metrics2.lib.MutableSizeHistogram
                        </shadedPattern>
                    </relocation>
                    <relocation>
                        <pattern>org.apache.hadoop.metrics2.lib.MutableTimeHistogram</pattern>
                        <shadedPattern>org.apache.hudi.org.apache.hadoop.metrics2.lib.MutableTimeHistogram
                        </shadedPattern>
                    </relocation>
                    <relocation>
                        <pattern>org.apache.hadoop.metrics2.util.MetricQuantile</pattern>
                        <shadedPattern>org.apache.hudi.org.apache.hadoop.metrics2.util.MetricQuantile
                        </shadedPattern>
                    </relocation>
                    <relocation>
                        <pattern>org.apache.hadoop.metrics2.util.MetricSampleQuantiles</pattern>
                        <shadedPattern>org.apache.hudi.org.apache.hadoop.metrics2.util.MetricSampleQuantiles
                        </shadedPattern>
                    </relocation>
                </relocations>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <transformers>
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>org.apache.hudi.timeline.service.TimelineService</mainClass>
                            </transformer>
                        </transformers>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
    </build>


    <properties>
        <checkstyle.skip>true</checkstyle.skip>
        <main.basedir>${project.parent.basedir}</main.basedir>
        <skipTests>true</skipTests>
    </properties>


</project>
