1apply plugin: 'kotlin'
2apply plugin: 'com.google.protobuf'
3
4// Generate IntelliJ IDEA's .idea & .iml project files
5// Starting with 0.8.4 of protobuf-gradle-plugin, *.proto and the gen output files are added
6// to IntelliJ as sources. It is no longer necessary to add them manually to the idea {} block
7// to jump to definitions from Java and Kotlin files.
8// For best results, install the Protobuf and Kotlin plugins for IntelliJ.
9apply plugin: 'idea'
10
11// Provide convenience executables for trying out the examples.
12apply plugin: 'application'
13
14
15buildscript {
16    ext.kotlin_version = '1.2.21'
17
18    repositories {
19        mavenCentral()
20        mavenLocal()
21    }
22    dependencies {
23        classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.5'
24        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
25    }
26}
27
28repositories {
29    mavenCentral()
30    mavenLocal()
31}
32
33// IMPORTANT: You probably want the non-SNAPSHOT version of gRPC. Make sure you
34// are looking at a tagged version of the example and not "master"!
35
36// Feel free to delete the comment at the next line. It is just for safely
37// updating the version in our release process.
38def grpcVersion = '1.16.1' // CURRENT_GRPC_VERSION
39
40dependencies {
41    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
42    compile "com.google.api.grpc:proto-google-common-protos:1.0.0"
43    compile "io.grpc:grpc-netty-shaded:${grpcVersion}"
44    compile "io.grpc:grpc-protobuf:${grpcVersion}"
45    compile "io.grpc:grpc-stub:${grpcVersion}"
46
47    testCompile "io.grpc:grpc-testing:${grpcVersion}" // gRCP testing utilities
48    testCompile "junit:junit:4.12"
49    testCompile "org.mockito:mockito-core:1.9.5"
50}
51
52protobuf {
53    protoc { artifact = 'com.google.protobuf:protoc:3.5.1-1' }
54    plugins {
55        grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
56    }
57    generateProtoTasks {
58        all()*.plugins { grpc {} }
59    }
60}
61
62startScripts.enabled = false
63
64task helloWorldServer(type: CreateStartScripts) {
65    mainClassName = 'io.grpc.examples.helloworld.HelloWorldServer'
66    applicationName = 'hello-world-server'
67    outputDir = new File(project.buildDir, 'tmp')
68    classpath = jar.outputs.files + project.configurations.runtime
69}
70
71task helloWorldClient(type: CreateStartScripts) {
72    mainClassName = 'io.grpc.examples.helloworld.HelloWorldClient'
73    applicationName = 'hello-world-client'
74    outputDir = new File(project.buildDir, 'tmp')
75    classpath = jar.outputs.files + project.configurations.runtime
76}
77
78applicationDistribution.into('bin') {
79    from(helloWorldServer)
80    from(helloWorldClient)
81    fileMode = 0755
82}
83