Skip to content

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

6.6 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.
 */
description = "catalog-lakehouse-iceberg"

plugins {
  `maven-publish`
  id("java")
  id("idea")
}

val scalaVersion: String = project.properties["scalaVersion"] as? String ?: extra["defaultScalaVersion"].toString()
val fullSparkVersion: String = libs.versions.spark34.get()
val sparkVersion = fullSparkVersion.split(".").take(2).joinToString(".")
val hudiVersion = libs.versions.hudi.get()

dependencies {
  compileOnly(project(":api"))
  compileOnly(project(":common"))
  compileOnly(project(":core"))

  compileOnly(libs.lombok)

  implementation(project(":catalogs:catalog-common")) {
    exclude("*")
  }
  implementation(project(":catalogs:hive-metastore-common"))

  implementation(libs.commons.collections3)
  implementation(libs.commons.configuration1) {
    exclude(group = "commons-beanutils")
  }
  implementation(libs.commons.io)
  implementation(libs.commons.lang3)
  implementation(libs.guava)
  implementation(libs.hadoop3.auth) {
    exclude("*")
  }
  implementation(libs.hadoop3.common) {
    exclude("*")
  }
  // Hadoop 3.x runtime requirements (stripped by exclude("*") above)
  implementation(libs.hadoop3.shaded.guava)
  implementation(libs.hadoop3.shaded.protobuf)
  implementation(libs.commons.configuration2)
  implementation(libs.re2j)
  implementation(libs.slf4j.api)
  implementation(libs.woodstox.core)

  annotationProcessor(libs.lombok)

  testImplementation(project(":api"))
  testImplementation(project(":catalogs:hive-metastore-common", "testArtifacts"))
  testImplementation(project(":clients:client-java")) {
    exclude("org.apache.logging.log4j")
  }
  testImplementation(project(":common"))
  testImplementation(project(":core"))
  testImplementation(project(":integration-test-common", "testArtifacts"))
  testImplementation(project(":server")) {
    exclude("org.apache.logging.log4j")
  }
  testImplementation(project(":server-common")) {
    exclude("org.apache.logging.log4j")
  }

  testImplementation("org.apache.spark:spark-hive_$scalaVersion:$fullSparkVersion") {
    exclude("org.apache.hadoop")
    exclude("io.dropwizard.metrics")
    exclude("com.fasterxml.jackson.core")
    exclude("com.fasterxml.jackson.module", "jackson-module-scala_2.12")
  }
  testImplementation("org.apache.spark:spark-hive_$scalaVersion:$fullSparkVersion") {
    exclude("org.apache.hadoop")
    exclude("io.dropwizard.metrics")
    exclude("com.fasterxml.jackson.core")
    exclude("com.fasterxml.jackson.module", "jackson-module-scala_2.12")
  }
  testImplementation("org.apache.spark:spark-sql_$scalaVersion:$fullSparkVersion") {
    exclude("org.apache.avro")
    exclude("org.apache.hadoop")
    exclude("org.apache.zookeeper")
    exclude("io.dropwizard.metrics")
    exclude("org.rocksdb")
  }
  testImplementation("org.apache.spark:spark-sql_$scalaVersion:$fullSparkVersion") {
    exclude("org.apache.avro")
    exclude("org.apache.hadoop")
    exclude("org.apache.zookeeper")
    exclude("io.dropwizard.metrics")
    exclude("org.rocksdb")
  }
  testImplementation(libs.awaitility)
  testImplementation(libs.bundles.jersey)
  testImplementation(libs.bundles.jetty)
  testImplementation(libs.commons.collections3)
  testImplementation(libs.commons.configuration1) {
    exclude(group = "commons-beanutils")
  }
  testImplementation(libs.datanucleus.api.jdo)
  testImplementation(libs.datanucleus.core)
  testImplementation(libs.datanucleus.jdo)
  testImplementation(libs.datanucleus.rdbms)
  testImplementation(libs.derby)
  testImplementation(libs.hadoop3.auth) {
    exclude("*")
  }
  testImplementation(libs.hadoop3.hdfs)
  testImplementation(libs.hadoop3.hdfs.client)
  testImplementation(libs.hadoop3.mapreduce.client.core) {
    exclude("*")
  }
  // Hadoop 3.x runtime requirements (stripped by exclude("*") above)
  testImplementation(libs.hadoop3.shaded.guava)
  testImplementation(libs.hadoop3.shaded.protobuf)
  testImplementation(libs.commons.configuration2)
  testImplementation(libs.re2j)
  testImplementation(libs.junit.jupiter.api)
  testImplementation(libs.mockito.core)
  testImplementation(libs.mysql.driver)
  testImplementation(libs.postgresql.driver)
  testImplementation(libs.prometheus.dropwizard)
  testImplementation(libs.testcontainers)

  testRuntimeOnly("org.apache.hudi:hudi-spark$sparkVersion-bundle_$scalaVersion:$hudiVersion")
  testRuntimeOnly(libs.junit.jupiter.engine)
}

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

  val copyCatalogLibs by registering(Copy::class) {
    dependsOn("jar", "runtimeJars")
    from("build/libs") {
      exclude("guava-*.jar")
      exclude("log4j-*.jar")
      exclude("slf4j-*.jar")
      exclude("error_prone_annotations-*.jar")
    }
    into("$rootDir/distribution/package/catalogs/lakehouse-hudi/libs")
  }

  val copyCatalogConfig by registering(Copy::class) {
    from("src/main/resources")
    into("$rootDir/distribution/package/catalogs/lakehouse-hudi/conf")

    include("lakehouse-hudi.conf")
    include("hive-site.xml.template")

    rename { original ->
      if (original.endsWith(".template")) {
        original.replace(".template", "")
      } else {
        original
      }
    }

    exclude { details ->
      details.file.isDirectory()
    }

    fileMode = 0b111101101
  }

  register("copyLibAndConfig", Copy::class) {
    dependsOn(copyCatalogLibs, copyCatalogConfig)
  }
}

tasks.test {
  // Hudi uses HiveClientClassLoader directly without depending on catalog-hive, so prepare the
  // version-specific Hive client and shim jars before its tests run.
  dependsOn(
    ":catalogs:hive-metastore2-libs:jar",
    ":catalogs:hive-metastore3-libs:jar"
  )

  val skipITs = project.hasProperty("skipITs")
  if (skipITs) {
    // Exclude integration tests
    exclude("**/integration/test/**")
  } else {
    dependsOn(tasks.jar)
  }
}

tasks.getByName("generateMetadataFileForMavenJavaPublication") {
  dependsOn("runtimeJars")
}