/*
 * Copyright © 2018-2019 Apple Inc. and the ServiceTalk project authors
 *
 * Licensed 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.
 */

apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"

ext.isNettySnapshot = "$nettyVersion".endsWithAny("SNAPSHOT", "+")

afterEvaluate {
  if (tasks.findByName("projectHealth")) {
    dependencyAnalysis {
      issues {
        // These are transitive dependencies of "org.apache.directory.server:apacheds-protocol-dns" and we don't want to
        // manage them manually because they are only used by testImplementation scope.
        onUsedTransitiveDependencies {
          exclude("org.apache.directory.server:apacheds-protocol-shared")
          exclude("org.apache.mina:mina-core")
        }
      }
    }
  }
}

dependencies {
  api project(":servicetalk-client-api")
  api project(":servicetalk-transport-api")

  implementation platform("io.netty:netty-bom:$nettyVersion")
  implementation project(":servicetalk-annotations")
  implementation project(":servicetalk-concurrent")
  implementation project(":servicetalk-concurrent-api")
  implementation project(":servicetalk-concurrent-api-internal")
  implementation project(":servicetalk-concurrent-internal")
  implementation project(":servicetalk-transport-netty-internal")
  implementation project(":servicetalk-utils-internal")
  implementation "io.netty:netty-buffer"
  implementation "io.netty:netty-common"
  implementation "io.netty:netty-codec-dns"
  implementation "io.netty:netty-resolver"
  implementation "io.netty:netty-resolver-dns"
  implementation "io.netty:netty-transport"
  implementation "org.slf4j:slf4j-api:$slf4jVersion"

  if (!project.ext.isNettySnapshot) {
    // Netty doesn't publish snapshots for macos artifacts
    runtimeOnly (group:"io.netty", name:"netty-resolver-dns-native-macos", classifier:"osx-x86_64")
    runtimeOnly (group:"io.netty", name:"netty-resolver-dns-native-macos", classifier:"osx-aarch_64")
  }

  testImplementation enforcedPlatform("org.junit:junit-bom:$junit5Version")
  testImplementation testFixtures(project(":servicetalk-concurrent-api"))
  testImplementation testFixtures(project(":servicetalk-concurrent-internal"))
  testImplementation testFixtures(project(":servicetalk-transport-netty-internal"))
  testImplementation project(":servicetalk-test-resources")
  testImplementation project(":servicetalk-concurrent-test-internal")
  testImplementation "org.junit.jupiter:junit-jupiter-api"
  testImplementation "org.junit.jupiter:junit-jupiter-params"
  testImplementation "org.apache.directory.server:apacheds-protocol-dns:$apacheDirectoryServerVersion"
  testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
  testImplementation "org.mockito:mockito-core:$mockitoCoreVersion"
}
