<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed 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">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>io.arenadata.hive</groupId>
    <artifactId>hive</artifactId>
    <version>2.3.10_arenadata1</version>
    <relativePath>../pom.xml</relativePath>
  </parent>

  <artifactId>hive-druid-handler</artifactId>
  <packaging>jar</packaging>
  <name>Hive Druid Handler</name>

  <properties>
    <hive.path.to.root>..</hive.path.to.root>
    <druid.metamx.util.version>0.27.10</druid.metamx.util.version>
    <druid.guava.version>16.0.1</druid.guava.version>
  </properties>

  <dependencies>
    <!-- dependencies are always listed in sorted order by groupId, artifectId -->
    <!-- intra-project -->
    <dependency>
      <groupId>com.fasterxml.jackson.dataformat</groupId>
      <artifactId>jackson-dataformat-smile</artifactId>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
    </dependency>
    <dependency>
      <groupId>io.arenadata.hive</groupId>
      <artifactId>hive-exec</artifactId>
      <version>${project.version}</version>
      <exclusions>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty-all</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.google.guava</groupId>
          <artifactId>guava</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <!-- inter-project -->
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>${commons-lang3.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>${druid.guava.version}</version>
    </dependency>
    <dependency>
      <groupId>com.metamx</groupId>
      <artifactId>java-util</artifactId>
      <version>${druid.metamx.util.version}</version>
      <exclusions>
        <exclusion>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-core</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-annotations</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-databind</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>joda-time</groupId>
      <artifactId>joda-time</artifactId>
      <version>${joda.version}</version>
    </dependency>
    <dependency>
      <groupId>io.druid</groupId>
      <artifactId>druid-server</artifactId>
      <version>${druid.version}</version>
      <exclusions>
        <exclusion>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-core</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-annotations</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-databind</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.druid</groupId>
          <artifactId>druid-aws-common</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>io.druid</groupId>
      <artifactId>druid-processing</artifactId>
      <version>${druid.version}</version>
      <exclusions>
        <exclusion>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-core</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-annotations</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-databind</artifactId>
        </exclusion>
        <exclusion>
          <!--LGPL licenced library-->
          <groupId>com.google.code.findbugs</groupId>
          <artifactId>annotations</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>io.druid.extensions</groupId>
      <artifactId>druid-hdfs-storage</artifactId>
      <version>${druid.version}</version>
      <exclusions>
        <exclusion>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-core</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-annotations</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-databind</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>io.druid.extensions</groupId>
      <artifactId>mysql-metadata-storage</artifactId>
      <version>${druid.version}</version>
       <exclusions>
        <exclusion>
          <groupId>mysql</groupId>
          <artifactId>mysql-connector-java</artifactId>
        </exclusion>
      </exclusions>
   </dependency>
    <dependency>
      <groupId>io.druid.extensions</groupId>
      <artifactId>postgresql-metadata-storage</artifactId>
      <version>${druid.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-common</artifactId>
      <scope>provided</scope>
      <version>${hadoop.version}</version>
      <optional>true</optional>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-log4j12</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.google.guava</groupId>
          <artifactId>guava</artifactId>
        </exclusion>
        <exclusion>
          <groupId>commmons-logging</groupId>
          <artifactId>commons-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <scope>provided</scope>
      <artifactId>hadoop-mapreduce-client-core</artifactId>
      <version>${hadoop.version}</version>
      <optional>true</optional>
      <exclusions>
        <exclusion>
          <groupId>com.google.inject</groupId>
          <artifactId>guice</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.google.inject.extensions</groupId>
          <artifactId>guice-servlet</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>netty</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.google.guava</groupId>
          <artifactId>guava</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.calcite</groupId>
      <artifactId>calcite-druid</artifactId>
      <version>${calcite.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.pentaho</groupId>
          <artifactId>pentaho-aggdesigner-algorithm</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.lmax</groupId>
      <artifactId>disruptor</artifactId>
      <version>${disruptor.version}</version>
    </dependency>
    <!-- test inter-project -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.druid</groupId>
      <artifactId>druid-indexing-hadoop</artifactId>
      <version>${druid.version}</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-core</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-annotations</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-databind</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>

  <build>
    <sourceDirectory>${basedir}/src/java</sourceDirectory>
    <testSourceDirectory>${basedir}/src/test</testSourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>test-jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>${maven.shade.plugin.version}</version>
        <executions>
          <!-- we need to shade netty, as there is a conflict between versions
          used by Hadoop (3.6.2.Final) and Druid (3.10.4.Final) -->
          <!-- we need to shade jackson, as there is a conflict between versions
          used by Hive (2.4.2) and Druid (2.4.6) -->
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <shadeTestJar>true</shadeTestJar>
              <createDependencyReducedPom>false</createDependencyReducedPom>
              <relocations>
                <relocation>
                  <pattern>io.druid</pattern>
                  <shadedPattern>org.apache.hive.druid.io.druid</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>com.metamx</pattern>
                  <shadedPattern>org.apache.hive.druid.com.metamx</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>io.netty</pattern>
                  <shadedPattern>org.apache.hive.druid.io.netty</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>org.apache.calcite</pattern>
                  <shadedPattern>org.apache.hive.druid.org.apache.calcite</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>org.jboss.netty</pattern>
                  <shadedPattern>org.apache.hive.druid.org.jboss.netty</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>com.fasterxml.jackson</pattern>
                  <shadedPattern>org.apache.hive.druid.com.fasterxml.jackson</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>com.google.common</pattern>
                  <shadedPattern>org.apache.hive.druid.com.google.common</shadedPattern>
                </relocation>
              </relocations>
              <artifactSet>
                <includes>
                  <include>io.druid:*</include>
                  <include>io.druid.extensions:*</include>
                  <include>com.metamx:*</include>
                  <include>io.netty:*</include>
                  <include>org.apache.calcite:*</include>
                  <include>com.fasterxml.jackson.core:*</include>
                  <include>com.fasterxml.jackson.datatype:*</include>
                  <include>com.fasterxml.jackson.dataformat:*</include>
                  <include>com.google.guava:*</include>
                  <include>it.unimi.dsi:*</include>
                  <include>org.jdbi:*</include>
                  <include>net.jpountz.lz4:*</include>
                  <include>org.apache.commons:*</include>
                </includes>
              </artifactSet>
              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                  </excludes>
                </filter>
              </filters>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
