Skip to content

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

5.4 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-fileset"

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

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

  compileOnly(libs.guava)

  implementation(project(":catalogs:catalog-common")) {
    exclude(group = "*")
  }
  implementation(project(":catalogs:hadoop-common")) {
    exclude(group = "*")
  }
  // hadoop-common's Kerberos path lives in :catalogs:hadoop-auth; bundle it into the
  // catalog runtime libs (the hadoop-common dependency above is non-transitive).
  implementation(project(":catalogs:hadoop-auth")) {
    exclude(group = "*")
  }

  implementation(libs.caffeine)
  implementation(libs.cglib)
  implementation(libs.commons.io)
  implementation(libs.commons.lang3)
  implementation(libs.hadoop3.client.api)
  implementation(libs.hadoop3.client.runtime)
  implementation(libs.metrics.caffeine)
  implementation(libs.metrics.core)
  implementation(libs.slf4j.api)

  testImplementation(project(":api"))
  testImplementation(project(":bundles:aliyun-bundle", configuration = "shadow"))
  testImplementation(project(":bundles:aws-bundle", configuration = "shadow"))
  testImplementation(project(":bundles:azure-bundle", configuration = "shadow"))
  testImplementation(project(":bundles:gcp-bundle", configuration = "shadow"))
  testImplementation(project(":bundles:tencent-bundle", configuration = "shadow"))
  testImplementation(project(":clients:client-java"))
  testImplementation(project(":common"))
  testImplementation(project(":core"))
  testImplementation(project(":integration-test-common", "testArtifacts"))
  testImplementation(project(":server"))
  testImplementation(project(":server-common"))
  testImplementation(libs.awaitility)
  testImplementation(libs.bundles.log4j)
  testImplementation(libs.hadoop3.gcs)
  testImplementation(libs.hadoop3.minicluster)
  testImplementation(libs.junit.jupiter.api)
  testImplementation(libs.junit.jupiter.params)
  testImplementation(libs.minikdc)
  testImplementation(libs.mockito.core)
  testImplementation(libs.mockito.inline)
  testImplementation(libs.mysql.driver)
  testImplementation(libs.postgresql.driver)
  testImplementation(libs.testcontainers)
  testImplementation(libs.testcontainers.mysql)

  // The RustFS fixture uses the S3 SDK v2; Hadoop's AWS bundle supplies the S3 SDK v1.
  testRuntimeOnly(libs.aws.s3)
  testRuntimeOnly(libs.junit.jupiter.engine)
}

tasks {
  register("runtimeJars", Copy::class) {
    from(configurations.runtimeClasspath)
    into("build/libs")
  }

  val copyCatalogLibs by registering(Copy::class) {
    dependsOn("jar", "runtimeJars")
    from("build/libs") {
      exclude("slf4j-*.jar")
      exclude("guava-*.jar")
      exclude("error_prone_annotations-*.jar")
      exclude("curator-*.jar")
      exclude("netty-*.jar")
      exclude("snappy-*.jar")
      exclude("zookeeper-*.jar")
      exclude("jetty-*.jar")
      exclude("javax.servlet-*.jar")
      exclude("kerb-*.jar")
      exclude("kerby-*.jar")
    }
    into("$rootDir/distribution/package/catalogs/fileset/libs")
  }

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

    include("fileset.conf")
    include("core-site.xml.template")
    include("hdfs-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(copyCatalogConfig, copyCatalogLibs)
  }
}

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

  // hadoop-client-api also contains the AuthenticationFilter of hadoop-auth, built against the
  // shaded servlet API. The MiniDFSCluster runs the unshaded hadoop-common, which needs the class of
  // hadoop-auth, so put hadoop-auth first instead of relying on the resolution order.
  val testClasspath = classpath
  val isHadoopAuth = { file: File -> file.name.startsWith("hadoop-auth-") }
  classpath = testClasspath.filter(isHadoopAuth) + testClasspath.filter { !isHadoopAuth(it) }

  // this task depends on :bundles:aws-bundle:jar
  dependsOn(":bundles:aws-bundle:jar")
  dependsOn(":bundles:aliyun-bundle:jar")
  dependsOn(":bundles:gcp-bundle:jar")
  dependsOn(":bundles:tencent-bundle:jar")
}

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