/*
 * Copyright © 2018-2020 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", "+")

dependencies {
  api platform("io.netty:netty-bom:$nettyVersion")
  api project(":servicetalk-buffer-api")
  api project(":servicetalk-concurrent")
  api project(":servicetalk-concurrent-api")
  api project(":servicetalk-concurrent-api-internal")
  api project(":servicetalk-logging-api")
  api project(":servicetalk-transport-api")
  api "io.netty:netty-buffer"
  api "io.netty:netty-common"
  api "io.netty:netty-handler"
  api "io.netty:netty-transport"

  implementation project(":servicetalk-annotations")
  implementation project(":servicetalk-buffer-netty")
  implementation project(":servicetalk-concurrent-internal")
  implementation project(":servicetalk-context-api")
  implementation project(":servicetalk-logging-slf4j-internal")
  implementation project(":servicetalk-utils-internal")
  implementation "io.netty:netty-codec"
  implementation "io.netty:netty-transport-classes-epoll"
  implementation "io.netty:netty-transport-classes-kqueue"
  implementation "io.netty:netty-transport-native-unix-common"
  implementation "org.slf4j:slf4j-api:$slf4jVersion"

  compileOnly "io.netty.incubator:netty-incubator-transport-classes-io_uring:$nettyIoUringVersion"

  runtimeOnly (group:"io.netty", name:"netty-tcnative-boringssl-static", classifier:"linux-x86_64")
  runtimeOnly (group:"io.netty", name:"netty-tcnative-boringssl-static", classifier:"linux-aarch_64")
  runtimeOnly (group:"io.netty", name:"netty-tcnative-boringssl-static", classifier:"osx-x86_64")
  runtimeOnly (group:"io.netty", name:"netty-tcnative-boringssl-static", classifier:"osx-aarch_64")
  runtimeOnly "io.netty:netty-transport-native-epoll"
  runtimeOnly (group:"io.netty", name:"netty-transport-native-epoll", classifier:"linux-x86_64")
  runtimeOnly (group:"io.netty", name:"netty-transport-native-epoll", classifier:"linux-aarch_64")
  runtimeOnly "io.netty:netty-transport-native-kqueue"
  if (!project.ext.isNettySnapshot) {
    // Netty doesn't publish snapshots for macos artifacts
    runtimeOnly (group:"io.netty", name:"netty-transport-native-kqueue", classifier:"osx-x86_64")
    runtimeOnly (group:"io.netty", name:"netty-transport-native-kqueue", classifier:"osx-aarch_64")
  }

  testImplementation enforcedPlatform("org.junit:junit-bom:$junit5Version")
  testImplementation testFixtures(project(":servicetalk-concurrent-api"))
  testImplementation testFixtures(project(":servicetalk-concurrent-internal"))
  testImplementation project(":servicetalk-test-resources")
  testImplementation project(":servicetalk-concurrent-api-test")
  testImplementation project(":servicetalk-concurrent-test-internal")
  testImplementation "org.junit.jupiter:junit-jupiter-api"
  testImplementation "org.junit.jupiter:junit-jupiter-params"
  testImplementation "org.hamcrest:hamcrest:$hamcrestVersion"
  testImplementation "org.mockito:mockito-core:$mockitoCoreVersion"
  testImplementation "org.mockito:mockito-junit-jupiter:$mockitoCoreVersion"

  testFixturesApi platform("io.netty:netty-bom:$nettyVersion")
  testFixturesApi platform("org.junit:junit-bom:$junit5Version")
  testFixturesApi project(":servicetalk-buffer-api")
  testFixturesApi project(":servicetalk-concurrent-api")
  testFixturesApi project(":servicetalk-transport-api")
  testFixturesApi "io.netty:netty-common"
  testFixturesApi "io.netty:netty-transport"
  testFixturesApi "org.junit.jupiter:junit-jupiter-api"

  testFixturesCompileOnly "io.netty.incubator:netty-incubator-transport-classes-io_uring:$nettyIoUringVersion"

  testFixturesImplementation project(":servicetalk-buffer-netty")
  testFixturesImplementation project(":servicetalk-utils-internal")
  testFixturesImplementation "com.google.code.findbugs:jsr305:$jsr305Version"
  testFixturesImplementation "org.mockito:mockito-core:$mockitoCoreVersion"
  testFixturesImplementation "org.slf4j:slf4j-api:$slf4jVersion"
}
