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


import java.nio.file.Paths

plugins {
    id('java-library')
    id('idea')
    id('maven-publish')
}

apply from: "$rootDir/gradle/common/publishing.gradle"

sourceCompatibility = 1.8

test {
    useJUnitPlatform()
    maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
    reports {
        junitXml.setRequired(true)
        def destDir = Paths.get(rootProject.rootDir.absolutePath, "build", "test-results", "vertx-client").toFile()
        println("Destination directory for vertx-client tests: ${destDir}")
        junitXml.getOutputLocation().set(destDir)
        html.setRequired(true)
        html.getOutputLocation().set(destDir)
    }
}

configurations {
    all*.exclude(group: 'ch.qos.logback')
}

dependencies {
    api(project(':client'))
    api(group: 'io.vertx', name: 'vertx-web-client', version: "${project.vertxVersion}") {
        exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
    }
    implementation(group: 'io.netty', name: 'netty-tcnative-boringssl-static', version: "${project.boringSslVersion}")  // for openSSL

    // The newer versions (2.0.48.Final+) of tcnative require explicit dependency declarations,
    // including the classifiers. See https://netty.io/wiki/forked-tomcat-native.html#gradle-and-bazel
    // for details.

    // openSSL native libraries for linux x86-64 architectures
    implementation(group: 'io.netty', name: 'netty-tcnative-boringssl-static', version: "${project.boringSslVersion}", classifier: 'linux-x86_64')
    // openSSL native libraries for macOS aarch-64 architectures
    implementation(group: 'io.netty', name: 'netty-tcnative-boringssl-static', version: "${project.boringSslVersion}", classifier: 'osx-aarch_64')
    // openSSL native libraries for linux aarch-64 architectures
    implementation(group: 'io.netty', name: 'netty-tcnative-boringssl-static', version: "${project.boringSslVersion}", classifier: 'linux-aarch_64')
    // openSSL native libraries for macOS x86-64 architectures
    implementation(group: 'io.netty', name: 'netty-tcnative-boringssl-static', version: "${project.boringSslVersion}", classifier: 'osx-x86_64')
    implementation("org.slf4j:slf4j-api:${project.slf4jVersion}")

    compileOnly('org.jetbrains:annotations:23.0.0')

    testImplementation(testFixtures(project(':client')))

    testImplementation("io.vertx:vertx-junit5:${project.vertxVersion}")
    testImplementation("org.assertj:assertj-core:3.24.2")
    testImplementation("org.junit.jupiter:junit-jupiter-api:${project.junitVersion}")
    testImplementation("org.junit.jupiter:junit-jupiter-params:${project.junitVersion}")
    testImplementation("com.squareup.okhttp3:mockwebserver:4.10.0")
    testImplementation('org.mockito:mockito-core:4.10.0')

    // logging dependencies for tests
    testImplementation("org.apache.logging.log4j:log4j-api:2.20.0")
    testImplementation("org.apache.logging.log4j:log4j-core:2.20.0")
    testImplementation("org.apache.logging.log4j:log4j-slf4j-impl:2.20.0")
}

spotbugsTest.enabled = false
check.dependsOn(checkstyleMain, checkstyleTest, jacocoTestReport)
