Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

5.5 KB
Raw Blame
/*
 * 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.
 */

import org.gradle.api.publish.maven.tasks.PublishToMavenLocal
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository

plugins {
  id("java")
  id("idea")
}

// Note: exclusion lists here are intentionally kept in sync with hive-metastore2-libs/build.gradle.kts.
// Guava and Logback are excluded because they are provided by the Gravitino runtime classpath.

dependencies {
  // Only needed to compile HiveShimV3 against the shared HiveShim base class, Gravitino's own
  // Column/HiveTable types (HiveTable extends core's BaseTable) and RandomNameUtils; compileOnly
  // keeps these classes out of the shaded runtime jar produced by copyDepends.
  compileOnly(project(":catalogs:hive-metastore-common"))
  compileOnly(project(":api"))
  compileOnly(project(":common"))
  compileOnly(project(":core"))
  compileOnly(libs.slf4j.api)

  // Force upgrades for outdated transitive dependencies pulled by Hive Metastore
  constraints {
    implementation(libs.thrift)
    implementation(libs.snappy.java)
    implementation(libs.commons.beanutils)
    implementation(libs.woodstox.core)
    // Not a new dependency: hadoop-common, hadoop-auth, Curator and the Hive shims already bring
    // ZooKeeper transitively, resolved to 3.6.3 (end of life). Gravitino does not use ZooKeeper; only
    // Hadoop/Hive code paths that Gravitino does not call (HA failover, ZooKeeper token stores and
    // discovery) reference it. This constraint only upgrades the version that is shipped.
    implementation(libs.zookeeper)
    implementation(libs.zookeeper.jute)
  }

  implementation(libs.hadoop3.common) {
    exclude(group = "ch.qos.logback")
    exclude(group = "ch.qos.reload4j")
    exclude(group = "com.fasterxml.jackson.core")
    exclude(group = "com.github.pjfanning", module = "jersey-json")
    exclude(group = "com.github.spotbugs")
    exclude(group = "com.google.code.findbugs")
    exclude(group = "com.google.guava")
    exclude(group = "com.sun.jersey")
    exclude(group = "log4j")
    exclude(group = "net.java.dev.jets3t")
    exclude(group = "org.apache.avro")
    exclude(group = "org.apache.logging.log4j")
    // hadoop-common 3.4 declares these, Hadoop 3.3 did not bring them. No Hadoop class on the
    // metastore client path uses them.
    exclude(group = "org.bouncycastle", module = "bcprov-jdk18on")
    exclude(group = "org.codehaus.jettison", module = "jettison")
    exclude(group = "org.eclipse.jetty")
    exclude(group = "org.slf4j")
  }
  implementation(libs.hive3.metastore) {
    exclude(group = "ant")
    exclude(group = "ch.qos.logback")
    exclude(group = "co.cask.tephra")
    exclude(group = "com.fasterxml.jackson.core")
    exclude(group = "com.github.joshelser")
    exclude(group = "com.github.spotbugs")
    exclude(group = "com.google.code.findbugs")
    exclude(group = "com.google.guava")
    exclude(group = "log4j")
    exclude(group = "com.tdunning", module = "json")
    exclude(group = "com.zaxxer", module = "HikariCP")
    exclude(group = "io.dropwizard.metrics")
    exclude(group = "javax.transaction", module = "transaction-api")
    exclude(group = "junit")
    exclude(group = "org.apache.ant")
    exclude(group = "org.apache.arrow")
    exclude(group = "org.apache.avro")
    exclude(group = "org.apache.derby")
    exclude(group = "org.apache.hadoop", module = "hadoop-yarn-server-resourcemanager")
    exclude(group = "org.apache.hbase")
    exclude(group = "org.apache.logging.log4j")
    exclude(group = "org.apache.parquet", module = "parquet-hadoop-bundle")
    exclude(group = "org.datanucleus")
    exclude(group = "org.eclipse.jetty")
    exclude(group = "org.openjdk.jol")
    exclude(group = "org.slf4j")
  }

  // compileOnly is not inherited by the test compile classpath, so the same set of Gravitino
  // modules used to compile HiveShimV3 needs to be redeclared for the test sources.
  testImplementation(project(":catalogs:hive-metastore-common"))
  testImplementation(project(":catalogs:catalog-common"))
  testImplementation(project(":api"))
  testImplementation(project(":common"))
  testImplementation(project(":core"))
  testImplementation(libs.slf4j.api)
  testImplementation(libs.junit.jupiter.api)
  testImplementation(libs.mockito.core)
  testRuntimeOnly(libs.junit.jupiter.engine)
}

tasks.withType<Test>().configureEach {
  useJUnitPlatform()
}

tasks {
  val copyDepends by registering(Copy::class) {
    from(configurations.runtimeClasspath)
    into("build/libs")
  }
  jar {
    finalizedBy(copyDepends)
  }

  register("copyLibs", Copy::class) {
    dependsOn(copyDepends, "build")
    from("build/libs")
    into("$rootDir/distribution/package/catalogs/hive/libs/hive-metastore3-libs")
  }
}

tasks.withType<PublishToMavenLocal>().configureEach { enabled = false }
tasks.withType<PublishToMavenRepository>().configureEach { enabled = false }