// 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.

plugins {
  id("java-library")
}

apply from: "$rootDir/gradle/shadow.gradle"

dependencies {
  implementation project(path: ":kudu-client")
  implementation project(path: ":kudu-proto")
  implementation libs.commonsIo
  implementation(libs.guava) {
    exclude(group: "com.google.errorprone")
  }
  implementation libs.httpClient
  implementation libs.httpMime
  implementation libs.osdetector
  implementation libs.protobufJava

  // Not shaded in the client JAR because it's part of the public API.
  compileUnshaded(libs.async) {
    // async uses versions ranges for slf4j making builds non-deterministic.
    // Remove this once the following is merged: https://github.com/OpenTSDB/async/pull/8
    exclude group: "org.slf4j", module: "slf4j-api"
  }

  compileOnlyApi libs.hamcrest
  compileUnshaded(libs.junit) {
    // Use the Kudu specified hamcrest.
    exclude group: "org.hamcrest"
  }
  compileUnshaded libs.slf4jApi

  // Support using any kudu-binary jar for tests via `-PuseBinJar=<version>`.
  if (propertyExists("useBinJar")) {
    apply plugin: "com.google.osdetector"
    def jarVersion = propertyWithDefault("useBinJar", project.version)
    runtimeOnly "org.apache.kudu:kudu-binary:$jarVersion:${osdetector.classifier}"
  }

  // Needed for CapturingLogAppender. Optional otherwise.
  compileOnlyApi libs.log4jApi
  compileOnlyApi libs.log4jCore
  compileOnlyApi libs.log4jSlf4jImpl

  compileOnlyApi libs.jsr305
  compileOnlyApi libs.yetusAnnotations

  testImplementation libs.jetty
  testImplementation libs.jettyServlet

  // Have to re-define some dependencies here, as compile-only dependencies
  // are not inherited by the test classpath.
  // See: https://blog.gradle.org/introducing-compile-only-dependencies
  // Note: compileUnshaded is extended from the compileOnly dependency scope.
  testImplementation libs.junit
  testImplementation libs.async
  testImplementation libs.hamcrest
  testImplementation libs.log4jApi
  testImplementation libs.log4jCore
  testImplementation libs.log4jSlf4jImpl
}

shadowJar {
  dependencies {
    exclude(dependency(libs.jsr305))
    exclude(dependency(libs.log4jApi))
    exclude(dependency(libs.log4jCore))
    exclude(dependency(libs.log4jSlf4jImpl))
    exclude(dependency(libs.junit))
    exclude(dependency("org.jacoco::.*"))
  }

  minimize()
}

// kudu-test-utils has no public Javadoc.
javadoc {
  enabled = false
}
