• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1apply plugin: 'java'
2apply plugin: 'com.google.protobuf'
3
4buildscript {
5    repositories {
6        maven { // The google mirror is less flaky than mavenCentral()
7            url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
8    }
9    dependencies { // ASSUMES GRADLE 2.12 OR HIGHER. Use plugin version 0.7.5 with earlier
10        // gradle versions
11        classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.5' }
12}
13
14repositories {
15    maven { // The google mirror is less flaky than mavenCentral()
16        url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
17    mavenLocal()
18}
19
20// IMPORTANT: You probably want the non-SNAPSHOT version of gRPC. Make sure you
21// are looking at a tagged version of the example and not "master"!
22
23// Feel free to delete the comment at the next line. It is just for safely
24// updating the version in our release process.
25def grpcVersion = '1.16.0-SNAPSHOT' // CURRENT_GRPC_VERSION
26def nettyTcNativeVersion = '2.0.7.Final'
27def protobufVersion = '3.5.1'
28def protocVersion = '3.5.1-1'
29
30dependencies {
31    compile "com.google.api.grpc:proto-google-common-protos:1.0.0"
32    compile "io.grpc:grpc-alts:${grpcVersion}"
33    compile "io.grpc:grpc-netty-shaded:${grpcVersion}"
34    compile "io.grpc:grpc-protobuf:${grpcVersion}"
35    compile "io.grpc:grpc-stub:${grpcVersion}"
36    compileOnly "javax.annotation:javax.annotation-api:1.2"
37
38    // Used in HelloWorldServerTls
39    compile "io.grpc:grpc-netty:${grpcVersion}"
40    compile "io.netty:netty-tcnative-boringssl-static:${nettyTcNativeVersion}"
41
42    compile "com.google.protobuf:protobuf-java-util:${protobufVersion}"
43
44    testCompile "io.grpc:grpc-testing:${grpcVersion}"
45    testCompile "junit:junit:4.12"
46    testCompile "org.mockito:mockito-core:1.9.5"
47}
48
49protobuf {
50    protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" }
51    plugins {
52        grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
53    }
54    generateProtoTasks {
55        all()*.plugins { grpc {} }
56    }
57}
58
59// Inform IDEs like IntelliJ IDEA, Eclipse or NetBeans about the generated code.
60sourceSets {
61    main {
62        java {
63            srcDirs 'build/generated/source/proto/main/grpc'
64            srcDirs 'build/generated/source/proto/main/java'
65        }
66    }
67}
68
69// Generate IntelliJ IDEA's .idea & .iml project files
70apply plugin: 'idea'
71
72// Provide convenience executables for trying out the examples.
73apply plugin: 'application'
74
75startScripts.enabled = false
76
77task routeGuideServer(type: CreateStartScripts) {
78    mainClassName = 'io.grpc.examples.routeguide.RouteGuideServer'
79    applicationName = 'route-guide-server'
80    outputDir = new File(project.buildDir, 'tmp')
81    classpath = jar.outputs.files + project.configurations.runtime
82}
83
84task routeGuideClient(type: CreateStartScripts) {
85    mainClassName = 'io.grpc.examples.routeguide.RouteGuideClient'
86    applicationName = 'route-guide-client'
87    outputDir = new File(project.buildDir, 'tmp')
88    classpath = jar.outputs.files + project.configurations.runtime
89}
90
91task helloWorldServer(type: CreateStartScripts) {
92    mainClassName = 'io.grpc.examples.helloworld.HelloWorldServer'
93    applicationName = 'hello-world-server'
94    outputDir = new File(project.buildDir, 'tmp')
95    classpath = jar.outputs.files + project.configurations.runtime
96}
97
98task helloWorldClient(type: CreateStartScripts) {
99    mainClassName = 'io.grpc.examples.helloworld.HelloWorldClient'
100    applicationName = 'hello-world-client'
101    outputDir = new File(project.buildDir, 'tmp')
102    classpath = jar.outputs.files + project.configurations.runtime
103}
104
105task helloWorldAltsServer(type: CreateStartScripts) {
106    mainClassName = 'io.grpc.examples.alts.HelloWorldAltsServer'
107    applicationName = 'hello-world-alts-server'
108    outputDir = new File(project.buildDir, 'tmp')
109    classpath = jar.outputs.files + project.configurations.runtime
110}
111
112task helloWorldAltsClient(type: CreateStartScripts) {
113    mainClassName = 'io.grpc.examples.alts.HelloWorldAltsClient'
114    applicationName = 'hello-world-alts-client'
115    outputDir = new File(project.buildDir, 'tmp')
116    classpath = jar.outputs.files + project.configurations.runtime
117}
118
119task helloWorldTlsServer(type: CreateStartScripts) {
120    mainClassName = 'io.grpc.examples.helloworldtls.HelloWorldServerTls'
121    applicationName = 'hello-world-tls-server'
122    outputDir = new File(project.buildDir, 'tmp')
123    classpath = jar.outputs.files + project.configurations.runtime
124}
125
126task helloWorldTlsClient(type: CreateStartScripts) {
127    mainClassName = 'io.grpc.examples.helloworldtls.HelloWorldClientTls'
128    applicationName = 'hello-world-tls-client'
129    outputDir = new File(project.buildDir, 'tmp')
130    classpath = jar.outputs.files + project.configurations.runtime
131}
132
133task compressingHelloWorldClient(type: CreateStartScripts) {
134    mainClassName = 'io.grpc.examples.experimental.CompressingHelloWorldClient'
135    applicationName = 'compressing-hello-world-client'
136    outputDir = new File(project.buildDir, 'tmp')
137    classpath = jar.outputs.files + project.configurations.runtime
138}
139
140applicationDistribution.into('bin') {
141    from(routeGuideServer)
142    from(routeGuideClient)
143    from(helloWorldServer)
144    from(helloWorldClient)
145    from(helloWorldAltsServer)
146    from(helloWorldAltsClient)
147    from(helloWorldTlsServer)
148    from(helloWorldTlsClient)
149    from(compressingHelloWorldClient)
150    fileMode = 0755
151}
152