/*
 * Copyright 2018 Google LLC
 *
 * 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
 *
 *     https://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 {
    ext.kotlin_version = '1.3.30'

    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

plugins {
    id "com.google.protobuf" version "0.8.8"
}

apply plugin: 'kotlin'
apply plugin: 'com.google.protobuf'

sourceCompatibility = 1.8

repositories {
    maven { url "/usr/local/kgax/repository" }
    google()
    mavenCentral()
    jcenter()
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation "javax.annotation:javax.annotation-api:1.3.2"

    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.0"

    compile("com.google.api:kgax-grpc:__KGAX__VERSION")
}

compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

// compile proto and generate gRPC stubs
protobuf {
    protoc {
        artifact = 'com.google.protobuf:protoc:3.7.1'
    }
    plugins {
        client {
            path = '/usr/generator/bin/generator'
        }
    }
    generateProtoTasks {
        all().each { task ->
            task.plugins {
                client {
                    option "source=${projectDir}/src/main/proto"
                    option "test-output=${project.buildDir}/generated/source/protoTest/clientTest"
                    // EXTRA-PLUGIN-OPTIONS
                }
            }
        }
    }
}
