blob: 3b1a860d5d480f9e81f4a239c465a1e1cfb72691 [file] [log] [blame]
Eric Andersond7bf67e2016-06-24 18:18:06 -07001apply plugin: 'java'
2apply plugin: 'com.google.protobuf'
Eric Anderson4ac4d492016-02-03 09:05:16 -08003
Eric Andersond7bf67e2016-06-24 18:18:06 -07004buildscript {
5 repositories {
6 mavenCentral()
7 }
8 dependencies {
9 // ASSUMES GRADLE 2.12 OR HIGHER. Use plugin version 0.7.5 with earlier
10 // gradle versions
Kun Zhang9d747bb2016-08-18 13:06:18 -070011 classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.0'
Eric Andersond7bf67e2016-06-24 18:18:06 -070012 }
13}
14
15repositories {
16 mavenCentral()
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.
Carl Mastrangelo17b90162017-04-11 14:51:39 -070025def grpcVersion = '1.4.0-SNAPSHOT' // CURRENT_GRPC_VERSION
Eric Andersond7bf67e2016-06-24 18:18:06 -070026
27dependencies {
28 compile "io.grpc:grpc-netty:${grpcVersion}"
29 compile "io.grpc:grpc-protobuf:${grpcVersion}"
30 compile "io.grpc:grpc-stub:${grpcVersion}"
ZHANG Dapeng7306df42016-11-15 14:15:55 -080031
32 testCompile "junit:junit:4.11"
33 testCompile "org.mockito:mockito-core:1.9.5"
Eric Andersond7bf67e2016-06-24 18:18:06 -070034}
35
36protobuf {
37 protoc {
Carl Mastrangelob0323ac2017-02-07 09:47:15 -080038 artifact = 'com.google.protobuf:protoc:3.2.0'
Eric Andersond7bf67e2016-06-24 18:18:06 -070039 }
40 plugins {
41 grpc {
42 artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
43 }
44 }
45 generateProtoTasks {
46 all()*.plugins {
ZHANG Dapenge1091252016-07-21 16:35:18 -070047 grpc {
48 // To generate deprecated interfaces and static bindService method,
49 // turn the enable_deprecated option to true below:
50 option 'enable_deprecated=false'
51 }
Eric Andersond7bf67e2016-06-24 18:18:06 -070052 }
53 }
54}
55
56// Inform IntelliJ projects about the generated code.
57apply plugin: 'idea'
58
59idea {
60 module {
61 // Not using generatedSourceDirs because of
62 // https://discuss.gradle.org/t/support-for-intellij-2016/15294/8
63 sourceDirs += file("${projectDir}/build/generated/source/proto/main/java");
64 sourceDirs += file("${projectDir}/build/generated/source/proto/main/grpc");
65 }
66}
67
68// Provide convenience executables for trying out the examples.
Jakob Buchgraber246e8b52015-02-18 13:26:48 -080069apply plugin: 'application'
Jakob Buchgraber246e8b52015-02-18 13:26:48 -080070
zhangkun83da3c3f82015-03-11 18:03:31 -070071startScripts.enabled = false
72
Eric Anderson1cf4cc82015-05-07 07:37:51 -070073task routeGuideServer(type: CreateStartScripts) {
Eric Andersond7bf67e2016-06-24 18:18:06 -070074 mainClassName = 'io.grpc.examples.routeguide.RouteGuideServer'
75 applicationName = 'route-guide-server'
76 outputDir = new File(project.buildDir, 'tmp')
77 classpath = jar.outputs.files + project.configurations.runtime
Jakob Buchgraber246e8b52015-02-18 13:26:48 -080078}
79
Eric Anderson1cf4cc82015-05-07 07:37:51 -070080task routeGuideClient(type: CreateStartScripts) {
Eric Andersond7bf67e2016-06-24 18:18:06 -070081 mainClassName = 'io.grpc.examples.routeguide.RouteGuideClient'
82 applicationName = 'route-guide-client'
83 outputDir = new File(project.buildDir, 'tmp')
84 classpath = jar.outputs.files + project.configurations.runtime
Jakob Buchgraber246e8b52015-02-18 13:26:48 -080085}
nmittler87daf0e2015-02-25 08:42:10 -080086
Eric Anderson1cf4cc82015-05-07 07:37:51 -070087task helloWorldServer(type: CreateStartScripts) {
Eric Andersond7bf67e2016-06-24 18:18:06 -070088 mainClassName = 'io.grpc.examples.helloworld.HelloWorldServer'
89 applicationName = 'hello-world-server'
90 outputDir = new File(project.buildDir, 'tmp')
91 classpath = jar.outputs.files + project.configurations.runtime
nmittler87daf0e2015-02-25 08:42:10 -080092}
93
Eric Anderson1cf4cc82015-05-07 07:37:51 -070094task helloWorldClient(type: CreateStartScripts) {
Eric Andersond7bf67e2016-06-24 18:18:06 -070095 mainClassName = 'io.grpc.examples.helloworld.HelloWorldClient'
96 applicationName = 'hello-world-client'
97 outputDir = new File(project.buildDir, 'tmp')
98 classpath = jar.outputs.files + project.configurations.runtime
Eric Anderson1cf4cc82015-05-07 07:37:51 -070099}
100
Carl Mastrangelo091749e2015-09-08 11:41:58 -0700101task compressingHelloWorldClient(type: CreateStartScripts) {
Eric Andersond7bf67e2016-06-24 18:18:06 -0700102 mainClassName = 'io.grpc.examples.experimental.CompressingHelloWorldClient'
103 applicationName = 'compressing-hello-world-client'
104 outputDir = new File(project.buildDir, 'tmp')
105 classpath = jar.outputs.files + project.configurations.runtime
Carl Mastrangelo091749e2015-09-08 11:41:58 -0700106}
107
Eric Andersond7bf67e2016-06-24 18:18:06 -0700108applicationDistribution.into('bin') {
109 from(routeGuideServer)
110 from(routeGuideClient)
111 from(helloWorldServer)
112 from(helloWorldClient)
113 from(compressingHelloWorldClient)
114 fileMode = 0755
Louis Ryana6234452015-03-12 13:46:14 -0700115}