plugins {
    id 'java-library'
    id 'com.google.protobuf'
    id 'maven-publish'
}

dependencies {
    api "com.google.protobuf:protobuf-java-util:${protobufVersion}"
    api "com.google.protobuf:protobuf-java:${protobufVersion}"
    api "io.grpc:grpc-protobuf:${grpcVersion}"
    api "io.grpc:grpc-stub:${grpcVersion}"

    implementation "com.google.guava:guava:${guavaVersion}"
    implementation "io.grpc:grpc-netty-shaded:${grpcVersion}"

    compileOnly 'javax.annotation:javax.annotation-api:1.3.2'

    testImplementation "com.google.code.gson:gson:${gsonVersion}"
    testImplementation "io.grpc:grpc-inprocess:${grpcVersion}"
    testImplementation "io.grpc:grpc-testing:${grpcVersion}"
}

sourceSets {
    main {
        proto {
            srcDir rootProject.file('../../src/ZB.MOM.WW.MxGateway.Contracts/Protos')
            include 'mxaccess_gateway.proto'
            include 'mxaccess_worker.proto'
            include 'galaxy_repository.proto'
        }
    }
}

java {
    withSourcesJar()
    withJavadocJar()
}

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

    plugins {
        grpc {
            artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
        }
    }

    generatedFilesBaseDir = rootProject.file('src/main/generated').absolutePath

    generateProtoTasks {
        all().configureEach {
            plugins {
                grpc {}
            }
        }
    }
}
