plugins {
    id "application"
    id "java"

    id "com.google.protobuf"
    id 'com.google.cloud.tools.jib'
    id "ru.vyarus.animalsniffer"
}

description = "gRPC: Istio Interop testing"

configurations {
    alpnagent
}

evaluationDependsOn(project(':grpc-context').path)

dependencies {
    implementation  project(':grpc-core'),
            project(':grpc-netty'),
            project(':grpc-protobuf'),
            project(':grpc-services'),
            project(':grpc-stub'),
            project(':grpc-testing'),
            project(':grpc-xds')

    compileOnly libraries.javax.annotation

    runtimeOnly libraries.netty.tcnative,
            libraries.netty.tcnative.classes
    testImplementation project(':grpc-context').sourceSets.test.output,
            project(':grpc-api').sourceSets.test.output,
            project(':grpc-core').sourceSets.test.output,
            libraries.mockito.core,
            libraries.junit,
            libraries.truth
    alpnagent libraries.jetty.alpn.agent

    signature libraries.signature.java
}

sourceSets {
    main {
        proto {
            srcDir 'third_party/istio/src/main/proto'
        }
    }
}

configureProtoCompilation()

import net.ltgt.gradle.errorprone.CheckSeverity

tasks.named("compileJava").configure {
    // This isn't a library; it can use beta APIs
    options.errorprone.check("BetaApi", CheckSeverity.OFF)
}


// For releasing to Docker Hub
jib {
    from.image = "gcr.io/distroless/java:8"
    container {
        ports = ['50051']
        mainClass="io.grpc.testing.istio.EchoTestServer"
    }
    outputPaths {
        tar = 'build/istio-echo-server.tar'
        digest = 'build/istio-echo-server.digest'
        imageId = 'build/istio-echo-server.id'
    }
}
