<?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>org.apache.hive</groupId>
    <artifactId>hive</artifactId>
    <version>3.1.3.333-eep-912</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>1.3.2</druid.metamx.util.version>
    <druid.guava.version>28.2-jre</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>org.apache.hive</groupId>
      <artifactId>hive-exec</artifactId>
      <version>${project.version}</version>
      <exclusions>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>*</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.google.guava</groupId>
          <artifactId>guava</artifactId>
        </exclusion>
        <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>
    <!-- inter-project -->
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <version>${commons-lang.version}</version>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty</artifactId>
      <version>${netty3.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>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>joda-time</groupId>
      <artifactId>joda-time</artifactId>
    </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>
        <exclusion>
          <groupId>org.eclipse.jetty</groupId>
          <artifactId>jetty-server</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.eclipse.jetty</groupId>
          <artifactId>jetty-proxy</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.eclipse.jetty</groupId>
          <artifactId>jetty-servlet</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.eclipse.jetty</groupId>
          <artifactId>jetty-servlets</artifactId>
        </exclusion>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.druid</groupId>
      <artifactId>druid-processing</artifactId>
      <version>${druid.version}</version>
      <exclusions>
        <exclusion>
          <!--LGPL licenced library-->
          <groupId>com.google.code.findbugs</groupId>
          <artifactId>annotations</artifactId>
        </exclusion>
      </exclusions>
      <optional>true</optional>
    </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>
        <exclusion>
          <groupId>org.apache.hadoop</groupId>
          <artifactId>hadoop-aws</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.amazonaws</groupId>
          <artifactId>aws-java-sdk-s3</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>
      <exclusions>
        <exclusion>
          <groupId>org.postgresql</groupId>
          <artifactId>postgresql</artifactId>
        </exclusion>
      </exclusions>
    </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>
        <exclusion>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-databind</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>*</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.google.guava</groupId>
          <artifactId>guava</artifactId>
        </exclusion>
        <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>
    <!-- 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>

  <profiles>
    <profile>
      <id>dev-fast-build</id>
      <activation>
        <property>
          <name>skipShade</name>
          <value>!true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <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>
                    <relocation>
                      <pattern>org.roaringbitmap</pattern>
                      <shadedPattern>org.apache.hive.druid.org.roaringbitmap</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>
                      <include>org.roaringbitmap:*</include>
                      <include>org.apache.derby:*</include>
                      <include>org.asynchttpclient:*</include>
                      <include>org.antlr:*</include>
                    </includes>
                  </artifactSet>
                  <filters>
                    <filter>
                      <artifact>*:*</artifact>
                      <excludes>
                        <exclude>META-INF/*.SF</exclude>
                        <exclude>META-INF/*.DSA</exclude>
                        <exclude>META-INF/*.RSA</exclude>
                        <exclude>META-INF/versions/**</exclude>
                        <exclude>static/</exclude>
                      </excludes>
                    </filter>
                  </filters>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <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>
    </plugins>
  </build>

</project>
