/*
 * Copyright © 2022 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.
 */

buildscript {
  dependencies {
    classpath "com.google.protobuf:protobuf-gradle-plugin:$protobufGradlePluginVersion"
  }
}

apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"
apply plugin: "com.google.protobuf"

def actualJerseyVersion = "${jerseyVersion}"
def actualJavaxAnnotationsApiVersion = "${javaxAnnotationsApiVersion}"
def actualJavaxInjectVersion = "${javaxInjectVersion}"
def actualJaxRsVersion = "${jaxRsVersion}"

// Dependencies must remain consistent between servicetalk-data-protobuf-jerseyX modules
dependencies {
  api platform("org.glassfish.jersey:jersey-bom:$actualJerseyVersion")
  api "jakarta.annotation:jakarta.annotation-api:$actualJavaxAnnotationsApiVersion" // Priority
  api "jakarta.ws.rs:jakarta.ws.rs-api:$actualJaxRsVersion" // MediaType, Feature
  api "org.glassfish.jersey.core:jersey-common" // AutoDiscoverable

  implementation platform("com.google.protobuf:protobuf-bom:$protobufVersion")
  implementation project(":servicetalk-annotations")
  implementation project(":servicetalk-buffer-api")
  implementation project(":servicetalk-concurrent-api")
  implementation project(":servicetalk-concurrent-internal")
  implementation project(":servicetalk-data-protobuf")
  implementation project(":servicetalk-http-api")
  implementation project(":servicetalk-http-router-jersey-internal")
  implementation project(":servicetalk-serializer-api")
  implementation project(":servicetalk-transport-api")
  implementation "com.google.protobuf:protobuf-java"
  implementation "org.glassfish.hk2.external:jakarta.inject:$actualJavaxInjectVersion"
  implementation "org.glassfish.jersey.core:jersey-server"
  implementation "org.slf4j:slf4j-api:$slf4jVersion"

  runtimeOnly project(":servicetalk-http-router-jersey")

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

  testCompileOnly "org.junit.platform:junit-platform-suite-api:$junitPlatformVersion"

  // BaseJerseyRouterTestSuite assumes JSON serialization is supported.
  testRuntimeOnly project(":servicetalk-data-jackson-jersey")
  testRuntimeOnly "org.glassfish.jersey.inject:jersey-hk2"
  testRuntimeOnly "org.glassfish.jersey.media:jersey-media-sse"
}

protobuf {
  protoc {
    artifact = "com.google.protobuf:protoc:$protobufVersion"
  }
}
