PHOENIX-5787 Do not package hive dependencies into phoenix-hive jar
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 5839864..dc8259e 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -33,4 +33,4 @@
     # The build doesn't seem to pick up the result of the install from above, so just re-compile
     # and the Maven reactor will find it just fine.
     - name: Test
-      run: mvn -B verify
+      run: mvn -B clean verify
diff --git a/phoenix-hive-base/phoenix4-hive/pom.xml b/phoenix-hive-base/phoenix4-hive/pom.xml
index dc09e3b..97f2479 100644
--- a/phoenix-hive-base/phoenix4-hive/pom.xml
+++ b/phoenix-hive-base/phoenix4-hive/pom.xml
@@ -35,12 +35,52 @@
   <properties>
     <hive.version>${hive2.version}</hive.version>
     <hive-storage.version>${hive2-storage.version}</hive-storage.version>
+    <log4j2.version>2.6.2</log4j2.version>
   </properties>
 
   <dependencies>
     <dependency>
       <groupId>org.apache.phoenix</groupId>
       <artifactId>phoenix-connectors-phoenix4-compat</artifactId>
+    <!-- Hive dependencies cannot be specified in the phoenix-hive-common, because of
+    hbase transitive dependency version conflicts -->
+    </dependency>
+        <dependency>
+      <groupId>org.apache.hive</groupId>
+      <artifactId>hive-cli</artifactId>
+      <version>${hive.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hive</groupId>
+      <artifactId>hive-common</artifactId>
+      <version>${hive.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hive</groupId>
+      <artifactId>hive-exec</artifactId>
+      <version>${hive.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <!-- These three dependencies are falsely flagged by dependency plugin -->
+    <dependency>
+      <groupId> org.apache.hive</groupId>
+      <artifactId>hive-serde</artifactId>
+      <version>${hive.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId> org.apache.hive</groupId>
+      <artifactId>hive-storage-api</artifactId>
+      <version>${hive-storage.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId> org.apache.hive.shims</groupId>
+      <artifactId>hive-shims-common</artifactId>
+      <version>${hive.version}</version>
+      <scope>provided</scope>
     </dependency>
     <!-- These are actually different between phoenix 5 and phoenix 4 -->
     <dependency>
@@ -71,7 +111,7 @@
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-assembly-plugin</artifactId>
+        <artifactId>maven-shade-plugin</artifactId>
       </plugin>
     </plugins>
   </build>
diff --git a/phoenix-hive-base/phoenix5-hive/pom.xml b/phoenix-hive-base/phoenix5-hive/pom.xml
index 22566e9..e9bede2 100644
--- a/phoenix-hive-base/phoenix5-hive/pom.xml
+++ b/phoenix-hive-base/phoenix5-hive/pom.xml
@@ -47,6 +47,52 @@
       <groupId>org.apache.phoenix</groupId>
       <artifactId>phoenix-connectors-phoenix5-compat</artifactId>
     </dependency>
+    <!-- Hive dependencies cannot be specified in the phoenix-hive-common, because of
+    hbase transitive dependency version conflicts -->
+    <dependency>
+      <groupId>org.apache.hive</groupId>
+      <artifactId>hive-cli</artifactId>
+      <version>${hive.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hive</groupId>
+      <artifactId>hive-common</artifactId>
+      <version>${hive.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hive</groupId>
+      <artifactId>hive-exec</artifactId>
+      <version>${hive.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <!-- These three dependencies are falsely flagged by dependency plugin -->
+    <dependency>
+      <groupId> org.apache.hive</groupId>
+      <artifactId>hive-serde</artifactId>
+      <version>${hive.version}</version>
+      <exclusions>
+        <!-- Fix conflict with Minicluster -->
+        <exclusion>
+          <groupId>io.netty</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+      </exclusions>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId> org.apache.hive</groupId>
+      <artifactId>hive-storage-api</artifactId>
+      <version>${hive-storage.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId> org.apache.hive.shims</groupId>
+      <artifactId>hive-shims-common</artifactId>
+      <version>${hive.version}</version>
+      <scope>provided</scope>
+    </dependency>
     <!-- These are actually different between phoenix 5 and phoenix 4 -->
     <dependency>
       <groupId> org.apache.hive</groupId>
@@ -57,21 +103,37 @@
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-mapreduce</artifactId>
-      <version>${hbase.version}</version>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-zookeeper</artifactId>
-      <version>${hbase.version}</version>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.hadoop</groupId>
       <artifactId>hadoop-mapreduce-client-core</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hbase</groupId>
+      <artifactId>hbase-protocol-shaded</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hbase</groupId>
+      <artifactId>hbase-endpoint</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hadoop</groupId>
+      <artifactId>hadoop-hdfs-client</artifactId>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-core</artifactId>
-      <version>2.14.0</version>
+      <version>${log4j2.version}</version>
       <scope>test</scope>
     </dependency>
     <dependency>
@@ -96,7 +158,7 @@
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-assembly-plugin</artifactId>
+        <artifactId>maven-shade-plugin</artifactId>
       </plugin>
     </plugins>
   </build>
diff --git a/phoenix-hive-base/pom.xml b/phoenix-hive-base/pom.xml
index 9ca011c..5120a07 100644
--- a/phoenix-hive-base/pom.xml
+++ b/phoenix-hive-base/pom.xml
@@ -33,6 +33,7 @@
   <name>Phoenix Hive Connector - Base</name>
 
   <packaging>pom</packaging>
+
   <modules>
     <module>phoenix4-hive</module>
     <module>phoenix5-hive</module>
@@ -64,63 +65,36 @@
       <artifactId>commons-lang3</artifactId>
       <version>${commons-lang3.version}</version>
     </dependency>
-    <dependency>
-      <groupId>org.apache.hive</groupId>
-      <artifactId>hive-cli</artifactId>
-      <version>${hive.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.hive</groupId>
-      <artifactId>hive-common</artifactId>
-      <version>${hive.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.hive</groupId>
-      <artifactId>hive-exec</artifactId>
-      <version>${hive.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <!-- These three dependencies are falsely flagged by dependency plugin -->
-    <dependency>
-      <groupId> org.apache.hive</groupId>
-      <artifactId>hive-serde</artifactId>
-      <version>${hive.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId> org.apache.hive</groupId>
-      <artifactId>hive-storage-api</artifactId>
-      <version>${hive-storage.version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId> org.apache.hive.shims</groupId>
-      <artifactId>hive-shims-common</artifactId>
-      <version>${hive.version}</version>
-      <scope>provided</scope>
-    </dependency>
 
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-protocol</artifactId>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-client</artifactId>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.hbase</groupId>
       <artifactId>hbase-common</artifactId>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.hadoop</groupId>
       <artifactId>hadoop-common</artifactId>
+      <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.hadoop</groupId>
       <artifactId>hadoop-mapreduce-client-core</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>provided</scope>
     </dependency>
 
     <dependency>
@@ -157,6 +131,12 @@
     <dependency>
       <groupId>org.apache.hadoop</groupId>
       <artifactId>hadoop-hdfs</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>io.netty</groupId>
+          <artifactId>netty</artifactId>
+        </exclusion>
+      </exclusions>
       <type>test-jar</type>
       <scope>test</scope>
     </dependency>
@@ -199,16 +179,83 @@
     <dependency>
       <groupId>org.apache.ant</groupId>
       <artifactId>ant</artifactId>
-      <scope>test</scope>
+      <scope>provided</scope>
       <version>1.9.1</version>
     </dependency>
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-api</artifactId>
-      <scope>test</scope>
-      <version>2.6.2</version>
+      <scope>provided</scope>
+      <version>${log4j2.version}</version>
     </dependency>
 
+
+<!-- Mark every HBase and Hadoop jar as provided -->
+    <dependency>
+      <groupId>org.apache.hbase</groupId>
+      <artifactId>hbase-annotations</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hbase</groupId>
+      <artifactId>hbase-metrics-api</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hbase</groupId>
+      <artifactId>hbase-metrics</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hbase</groupId>
+      <artifactId>hbase-server</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hbase</groupId>
+      <artifactId>hbase-hadoop-compat</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hbase</groupId>
+      <artifactId>hbase-hadoop2-compat</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hbase.thirdparty</groupId>
+      <artifactId>hbase-shaded-miscellaneous</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hbase.thirdparty</groupId>
+      <artifactId>hbase-shaded-protobuf</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hadoop</groupId>
+      <artifactId>hadoop-annotations</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hadoop</groupId>
+      <artifactId>hadoop-auth</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.hadoop</groupId>
+      <artifactId>hadoop-yarn-api</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.zookeeper</groupId>
+      <artifactId>zookeeper</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>com.google.protobuf</groupId>
+      <artifactId>protobuf-java</artifactId>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
 
   <build>
@@ -217,46 +264,22 @@
         <plugin>
           <artifactId>maven-dependency-plugin</artifactId>
           <configuration>
+            <ignoreNonCompile>true</ignoreNonCompile>
             <ignoredUnusedDeclaredDependencies>
-              <!-- These are all used -->
               <ignoredUnusedDeclaredDependency>
-                org.apache.hive:hive-serde
+                 org.slf4j:slf4j-api
               </ignoredUnusedDeclaredDependency>
               <ignoredUnusedDeclaredDependency>
-                org.apache.hive:hive-storage-api
-              </ignoredUnusedDeclaredDependency>
-              <ignoredUnusedDeclaredDependency>
-                org.apache.hive.shims:hive-shims-common
-              </ignoredUnusedDeclaredDependency>
-              <ignoredUnusedDeclaredDependency>
-                org.apache.hbase:hbase-it
-              </ignoredUnusedDeclaredDependency>
-              <ignoredUnusedDeclaredDependency>
-                org.apache.tez:tez-tests
-              </ignoredUnusedDeclaredDependency>
-              <ignoredUnusedDeclaredDependency>
-                org.apache.tez:tez-dag
-              </ignoredUnusedDeclaredDependency>
-              <ignoredUnusedDeclaredDependency>
-                org.apache.logging.log4j:log4j-core
-              </ignoredUnusedDeclaredDependency>
-              <ignoredUnusedDeclaredDependency>
-                org.apache.hadoop:hadoop-minicluster
-              </ignoredUnusedDeclaredDependency>
-              <ignoredUnusedDeclaredDependency>
-                org.apache.hadoop:hadoop-hdfs
+                org.apache.commons:commons-lang3
               </ignoredUnusedDeclaredDependency>
             </ignoredUnusedDeclaredDependencies>
             <ignoredUsedUndeclaredDependencies>
               <!-- I couldn't find it referenced anywhere in the phoenix-hive codebase -->
-              <ignoredUnusedDeclaredDependency>
-                com.google.code.findbugs:jsr305
-              </ignoredUnusedDeclaredDependency>
-              <!-- This one is real, but I don't want to force users to specify both
-                HBase AND Zookeeper versions so we'll just pretend that it's declared properly, 
-                and take whatever version we get -->
               <ignoredUsedUndeclaredDependency>
-                org.apache.zookeeper:zookeeper
+                com.google.code.findbugs:jsr305
+              </ignoredUsedUndeclaredDependency>
+              <ignoredUsedUndeclaredDependency>
+                org.apache.calcite.avatica:avatica
               </ignoredUsedUndeclaredDependency>
             </ignoredUsedUndeclaredDependencies>
           </configuration>
@@ -339,27 +362,6 @@
           </executions>
         </plugin>
         <plugin>
-          <artifactId>maven-assembly-plugin</artifactId>
-          <configuration>
-            <descriptorRefs>
-              <descriptorRef>jar-with-dependencies</descriptorRef>
-            </descriptorRefs>
-          </configuration>
-          <executions>
-            <execution>
-              <id>make-jar-with-dependencies</id>
-              <phase>package</phase>
-              <goals>
-                <goal>single</goal>
-              </goals>
-              <configuration>
-                <appendAssemblyId>false</appendAssemblyId>
-                <finalName>phoenix${phoenix.main.version}-${project.version}-hive</finalName>
-              </configuration>
-            </execution>
-          </executions>
-        </plugin>
-        <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-compiler-plugin</artifactId>
           <configuration>
@@ -367,6 +369,220 @@
             <target>8</target>
           </configuration>
         </plugin>
+        <!-- Taken from phoenix-client-parent
+        this should be kept in sync with Phoenix as much as possible -->
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-shade-plugin</artifactId>
+          <configuration>
+            <finalName>phoenix${phoenix.main.version}-${project.version}-hive</finalName>
+            <shadedArtifactAttached>true</shadedArtifactAttached>
+            <filters>
+              <filter>
+                <artifact>*:*</artifact>
+                <excludes>
+                  <exclude>META-INF/*.SF</exclude>
+                  <exclude>META-INF/*.DSA</exclude>
+                  <exclude>META-INF/*.RSA</exclude>
+                  <exclude>META-INF/license/*</exclude>
+                  <exclude>META-INF/NOTICE</exclude>
+                  <exclude>LICENSE.*</exclude>
+                  <exclude>NOTICE.*</exclude>
+                  <exclude>NOTICE</exclude>
+                  <exclude>README*</exclude>
+                </excludes>
+              </filter>
+             <filter>
+                <artifact>org.apache.hadoop:hadoop-yarn-common</artifact>
+                <excludes>
+                  <exclude>org/apache/hadoop/yarn/factories/package-info.class</exclude>
+                  <exclude>org/apache/hadoop/yarn/util/package-info.class</exclude>
+                  <exclude>org/apache/hadoop/yarn/factory/providers/package-info.class</exclude>
+                  <exclude>org/apache/hadoop/yarn/client/api/impl/package-info.class</exclude>
+                  <exclude>org/apache/hadoop/yarn/client/api/package-info.class</exclude>
+                  <exclude>webapps/**</exclude>
+                </excludes>
+              </filter>
+              <!-- Phoenix specific -->
+              <filter>
+                <artifact>org.apache.commons:commons-math3</artifact>
+                <excludes>
+                  <exclude>assets/**</exclude>
+                </excludes>
+              </filter>
+              <filter>
+                <artifact>org.apache.hbase:hbase-server</artifact>
+                <excludes>
+                  <exclude>hbase-webapps/**</exclude>
+                </excludes>
+              </filter>
+              <!-- Phoenix specific -->
+            </filters>
+            <transformers>
+              <transformer
+                  implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
+              <transformer
+                  implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+                <resource>csv-bulk-load-config.properties</resource>
+                <file>
+                  ${project.basedir}/../config/csv-bulk-load-config.properties
+                </file>
+              </transformer>
+              <transformer
+                  implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+                <resource>README.md</resource>
+                <file>${project.basedir}/../README.md</file>
+              </transformer>
+              <transformer
+                  implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+                <resource>LICENSE.txt</resource>
+                <file>${project.basedir}/../LICENSE</file>
+              </transformer>
+              <transformer
+                  implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
+                <resource>NOTICE</resource>
+                <file>${project.basedir}/../NOTICE</file>
+              </transformer>
+            </transformers>
+            <relocations>
+              <relocation>
+                <pattern>org/</pattern>
+                <shadedPattern>${shaded.package}.org.</shadedPattern>
+                <excludes>
+                  <exclude>org/apache/hadoop/**</exclude>
+                  <!-- Our non-shaded htrace and logging libraries -->
+                  <exclude>org/apache/htrace/**</exclude>
+                  <exclude>org/slf4j/**</exclude>
+                  <exclude>org/apache/commons/logging/**</exclude>
+                  <exclude>org/apache/log4j/**</exclude>
+                  <!-- Not the org/ packages that are a part of the jdk -->
+                  <exclude>org/ietf/jgss/**</exclude>
+                  <exclude>org/omg/**</exclude>
+                  <exclude>org/w3c/dom/**</exclude>
+                  <exclude>org/xml/sax/**</exclude>
+                  <!-- Extras compared to Hadoop -->
+                  <!-- Hbase classes - Maybe these could be shaded as well ? -->
+                  <exclude>org/apache/hbase/**</exclude>
+                  <!-- Phoenix classes -->
+                  <exclude>org/apache/phoenix/**</exclude>
+                  <exclude>org/apache/omid/**</exclude>
+                  <!-- Do want/need to expose Tephra as well ? -->
+                </excludes>
+              </relocation>
+              <relocation>
+                <pattern>com/</pattern>
+                <shadedPattern>${shaded.package}.com.</shadedPattern>
+                <excludes>
+                  <!-- Not the com/ packages that are a part of particular jdk implementations -->
+                  <exclude>com/sun/tools/**</exclude>
+                  <exclude>com/sun/javadoc/**</exclude>
+                  <exclude>com/sun/security/**</exclude>
+                  <exclude>com/sun/jndi/**</exclude>
+                  <exclude>com/sun/management/**</exclude>
+                  <!-- We are getting unshaded HBase from Hive, we must leave protobuf generated
+                  classes alone -->
+                  <exclude>com/google/protobuf/**</exclude>
+                </excludes>
+              </relocation>
+              <relocation>
+                <pattern>io/</pattern>
+                <shadedPattern>${shaded.package}.io.</shadedPattern>
+                <excludes>
+                  <!-- Exclude config keys for Hadoop that look like package names -->
+                  <exclude>io/compression/**</exclude>
+                  <exclude>io/mapfile/**</exclude>
+                  <exclude>io/map/index/*</exclude>
+                  <exclude>io/seqfile/**</exclude>
+                  <exclude>io/file/buffer/size</exclude>
+                  <exclude>io/skip/checksum/errors</exclude>
+                  <exclude>io/sort/*</exclude>
+                  <exclude>io/serializations</exclude>
+                </excludes>
+              </relocation>
+              <!-- JSRs that haven't made it to inclusion in J2SE -->
+              <relocation>
+                <pattern>javax/el/</pattern>
+                <shadedPattern>${shaded.package}.javax.el.</shadedPattern>
+              </relocation>
+              <relocation>
+                <pattern>javax/cache/</pattern>
+                <shadedPattern>${shaded.package}.javax.cache.</shadedPattern>
+              </relocation>
+              <relocation>
+                <pattern>javax/servlet/</pattern>
+                <shadedPattern>${shaded.package}.javax.servlet.</shadedPattern>
+              </relocation>
+              <relocation>
+                <pattern>javax/ws/</pattern>
+                <shadedPattern>${shaded.package}.javax.ws.</shadedPattern>
+              </relocation>
+              <relocation>
+                <pattern>javax/annotation/</pattern>
+                <shadedPattern>${shaded.package}.javax.annotation.</shadedPattern>
+              </relocation>
+              <relocation>
+                <pattern>javax/inject/</pattern>
+                <shadedPattern>${shaded.package}.javax.inject.</shadedPattern>
+              </relocation>
+              <relocation>
+                <pattern>javax/validation/</pattern>
+                <shadedPattern>${shaded.package}.javax.validation.</shadedPattern>
+            </relocation>
+              <relocation>
+                <pattern>net/</pattern>
+                <shadedPattern>${shaded.package}.net.</shadedPattern>
+                <excludes>
+                  <!-- Exclude config keys for Hadoop that look like package names -->
+                  <exclude>net/topology/**</exclude>
+                </excludes>
+              </relocation>
+              <!-- okio declares a top level package instead of nested -->
+              <relocation>
+                <pattern>okio/</pattern>
+                <shadedPattern>${shaded.package}.okio.</shadedPattern>
+              </relocation>
+              <!-- Phoenix specific relocations -->
+              <relocation>
+                <!-- Tephra -->
+                <pattern>co/</pattern>
+                <shadedPattern>${shaded.package}.co.</shadedPattern>
+              </relocation>
+              <relocation>
+                <pattern>it/</pattern>
+                <shadedPattern>${shaded.package}.it.</shadedPattern>
+              </relocation>
+              <relocation>
+                <pattern>javassist/</pattern>
+                <shadedPattern>${shaded.package}.javassist.</shadedPattern>
+              </relocation>
+              <relocation>
+                <pattern>jersey/</pattern>
+                <shadedPattern>${shaded.package}.jersey.</shadedPattern>
+              </relocation>
+              <relocation>
+                <pattern>jline/</pattern>
+                <shadedPattern>${shaded.package}.jline.</shadedPattern>
+              </relocation>
+              <relocation>
+                <pattern>mozilla/</pattern>
+                <shadedPattern>${shaded.package}.mozilla.</shadedPattern>
+              </relocation>
+              <relocation>
+                <pattern>tables/</pattern>
+                <shadedPattern>${shaded.package}.tables.</shadedPattern>
+              </relocation>
+              <!-- Phoenix specific relocations end -->
+            </relocations>
+          </configuration>
+          <executions>
+            <execution>
+              <phase>package</phase>
+              <goals>
+                <goal>shade</goal>
+              </goals>
+            </execution>
+          </executions>
+        </plugin>
       </plugins>
     </pluginManagement>
   </build>
diff --git a/phoenix-hive-base/src/main/java/org/apache/phoenix/hive/PhoenixMetaHook.java b/phoenix-hive-base/src/main/java/org/apache/phoenix/hive/PhoenixMetaHook.java
index 0e1811b..82c9c14 100644
--- a/phoenix-hive-base/src/main/java/org/apache/phoenix/hive/PhoenixMetaHook.java
+++ b/phoenix-hive-base/src/main/java/org/apache/phoenix/hive/PhoenixMetaHook.java
@@ -75,6 +75,7 @@
                 LOG.debug("Phoenix table " + tableName + " was created");
             }
         } catch (SQLException e) {
+            LOG.warn("error while creating table", e);
             throw new MetaException(e.getMessage());
         }
     }
@@ -223,6 +224,7 @@
                 }
             }
         } catch (SQLException e) {
+            LOG.warn("error while dropping table", e);
             throw new MetaException(e.getMessage());
         }
     }
diff --git a/phoenix-hive-base/src/main/java/org/apache/phoenix/hive/util/PhoenixConnectionUtil.java b/phoenix-hive-base/src/main/java/org/apache/phoenix/hive/util/PhoenixConnectionUtil.java
index e0a6ec6..df28d76 100644
--- a/phoenix-hive-base/src/main/java/org/apache/phoenix/hive/util/PhoenixConnectionUtil.java
+++ b/phoenix-hive-base/src/main/java/org/apache/phoenix/hive/util/PhoenixConnectionUtil.java
@@ -82,7 +82,7 @@
         try {
             Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
         } catch (ClassNotFoundException e) {
-            LOG.warn("internal error",e);
+            LOG.warn("Coould not load driver",e);
         }
         return DriverManager.getConnection(QueryUtil.getUrl(zookeeperQuorum, clientPort,
                 zNodeParent));
diff --git a/phoenix5-connectors-assembly/pom.xml b/phoenix5-connectors-assembly/pom.xml
index 0b06458..a48238e 100644
--- a/phoenix5-connectors-assembly/pom.xml
+++ b/phoenix5-connectors-assembly/pom.xml
@@ -28,6 +28,13 @@
     <version>6.0.0-SNAPSHOT</version>
   </parent>
 
+  <properties>
+    <phoenix.version>${phoenix-five.version}</phoenix.version>
+    <hbase.version>${hbase-two.version}</hbase.version>
+    <hadoop.version>${hadoop-three.version}</hadoop.version>
+    <jdk.version>1.8</jdk.version>
+  </properties>
+
   <artifactId>phoenix5-connectors-assembly</artifactId>
   <packaging>pom</packaging>
   <name>Phoenix 5 Connectors Distribution Assembly</name>
diff --git a/pom.xml b/pom.xml
index b6148ae..bcaf6fc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,6 +41,19 @@
     <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/phoenix-connectors.git</developerConnection>
   </scm>
 
+  <modules>
+      <module>phoenix-connectors-phoenix4-compat</module>
+      <module>phoenix-connectors-phoenix5-compat</module>
+      <!-- Changing the module order here may cause maven to get stuck in an infinite loop -->
+      <module>phoenix-hive-base</module>
+      <module>phoenix-flume-base</module>
+      <module>phoenix-pig-base</module>
+      <module>phoenix-kafka-base</module>
+      <module>phoenix-spark-base</module>
+      <module>phoenix4-connectors-assembly</module>
+      <module>phoenix5-connectors-assembly</module>
+  </modules>
+
   <properties>
     <!-- Phoenix Version -->
     <phoenix-four.version>4.15.0-HBase-1.4</phoenix-four.version>
@@ -48,7 +61,8 @@
     <phoenix.thirdparty.version>1.0.0</phoenix.thirdparty.version>
     <!-- Hadoop Versions -->
     <hbase-one.version>1.4.0</hbase-one.version>
-    <hbase-two.version>2.1.9</hbase-two.version>
+    <hbase-two.version>2.1.10</hbase-two.version>
+    <hbase-thirdparty-version>2.2.1</hbase-thirdparty-version>
     <hadoop-two.version>2.7.5</hadoop-two.version>
     <hadoop-three.version>3.0.3</hadoop-three.version>
 
@@ -77,6 +91,7 @@
     <scala.binary.version>2.11</scala.binary.version>
     
     <log4j.version>1.2.17</log4j.version>
+    <log4j2.version>2.10.0</log4j2.version>
     <disruptor.version>3.3.6</disruptor.version>
     <slf4j.version>1.7.30</slf4j.version>
     <commons-collections.version>3.2.2</commons-collections.version>
@@ -523,6 +538,51 @@
       </dependency>
 
       <!-- HBase dependencies -->
+
+      <!-- These are only needed so that we can set them provided and exclude from the shaded jars -->
+      <dependency>
+        <groupId>org.apache.hbase</groupId>
+        <artifactId>hbase-protocol-shaded</artifactId>
+        <version>${hbase.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.hbase</groupId>
+        <artifactId>hbase-metrics-api</artifactId>
+        <version>${hbase.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.hbase</groupId>
+        <artifactId>hbase-metrics</artifactId>
+        <version>${hbase.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.hbase</groupId>
+        <artifactId>hbase-endpoint</artifactId>
+        <version>${hbase.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.hbase</groupId>
+        <artifactId>hbase-mapreduce</artifactId>
+        <version>${hbase.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.hbase</groupId>
+        <artifactId>hbase-zookeeper</artifactId>
+        <version>${hbase.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.hbase.thirdparty</groupId>
+        <artifactId>hbase-shaded-miscellaneous</artifactId>
+        <version>${hbase-thirdparty-version}</version>
+        <scope>provided</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.hbase.thirdparty</groupId>
+        <artifactId>hbase-shaded-protobuf</artifactId>
+        <version>${hbase-thirdparty-version}</version>
+      </dependency>
+      <!-- End of exclusion-only dependencies -->
+
       <dependency>
         <groupId>org.apache.hbase</groupId>
         <artifactId>hbase-annotations</artifactId>
@@ -625,6 +685,20 @@
       </dependency>
 
       <!-- Hadoop Dependencies -->
+
+      <!-- Start for exclusion only -->
+      <dependency>
+        <groupId>org.apache.hadoop</groupId>
+        <artifactId>hadoop-yarn-api</artifactId>
+        <version>${hadoop.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.hadoop</groupId>
+        <artifactId>hadoop-hdfs-client</artifactId>
+        <version>${hadoop.version}</version>
+      </dependency>
+      <!-- End for exclusion only -->
+
       <dependency>
         <groupId>org.apache.hadoop</groupId>
         <artifactId>hadoop-common</artifactId>
@@ -700,11 +774,38 @@
 
       <!-- General Dependencies -->
       <dependency>
+        <groupId>org.apache.zookeeper</groupId>
+        <artifactId>zookeeper</artifactId>
+        <version>${zookeeper.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.zookeeper</groupId>
+        <artifactId>zookeeper-jute</artifactId>
+        <version>${zookeeper.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>com.google.protobuf</groupId>
+        <artifactId>protobuf-java</artifactId>
+        <version>2.5.0</version>
+      </dependency>
+      <dependency>
+        <groupId>commons-logging</groupId>
+        <artifactId>commons-logging</artifactId>
+        <version>${commons-logging.version}</version>
+      </dependency>
+
+      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-api</artifactId>
         <version>${slf4j.version}</version>
       </dependency>
       <dependency>
+        <!-- for exclusion -->
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-log4j12</artifactId>
+        <version>${slf4j.version}</version>
+      </dependency>
+      <dependency>
         <groupId>org.apache.pig</groupId>
         <artifactId>pig</artifactId>
         <version>${pig.version}</version>
@@ -769,42 +870,6 @@
   </dependencyManagement>
 
   <profiles>
-    <profile>
-    <id>phoenix4</id>
-      <activation>
-        <property>
-          <name>!skip-phoenix4</name>
-        </property>
-      </activation>
-    <modules>
-      <module>phoenix-connectors-phoenix4-compat</module>
-      <module>phoenix-flume-base/phoenix4-flume</module>
-      <module>phoenix-pig-base/phoenix4-pig</module>
-      <module>phoenix-kafka-base/phoenix4-kafka</module>
-      <module>phoenix-spark-base/phoenix4-spark</module>
-      <module>phoenix-hive-base/phoenix4-hive</module>
-      <module>phoenix4-connectors-assembly</module>
-    </modules>
-  </profile>
-    <profile>
-      <id>phoenix5</id>
-      <activation>
-        <property>
-          <name>!skip-phoenix5</name>
-        </property>
-      </activation>
-      <properties>
-      </properties>
-      <modules>
-        <module>phoenix-connectors-phoenix5-compat</module>
-        <module>phoenix-flume-base/phoenix5-flume</module>
-        <module>phoenix-pig-base/phoenix5-pig</module>
-        <module>phoenix-kafka-base/phoenix5-kafka</module>
-        <module>phoenix-spark-base/phoenix5-spark</module>
-        <module>phoenix-hive-base/phoenix5-hive</module>
-        <module>phoenix5-connectors-assembly</module>
-      </modules>
-    </profile>
     <!-- disable doclint with 1.8+ JDKs-->
     <profile>
       <id>java8-doclint-disabled</id>
@@ -832,19 +897,6 @@
               </execution>
             </executions>
           </plugin>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-gpg-plugin</artifactId>
-            <executions>
-              <execution>
-                <id>sign-artifacts</id>
-                <phase>verify</phase>
-                <goals>
-                  <goal>sign</goal>
-                </goals>
-              </execution>
-            </executions>
-          </plugin>
         </plugins>
       </build>
     </profile>