Eric Anderson | d7bf67e | 2016-06-24 18:18:06 -0700 | [diff] [blame] | 1 | apply plugin: 'java' |
| 2 | apply plugin: 'com.google.protobuf' |
Eric Anderson | 4ac4d49 | 2016-02-03 09:05:16 -0800 | [diff] [blame] | 3 | |
Eric Anderson | d7bf67e | 2016-06-24 18:18:06 -0700 | [diff] [blame] | 4 | buildscript { |
| 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 Zhang | 9d747bb | 2016-08-18 13:06:18 -0700 | [diff] [blame] | 11 | classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.0' |
Eric Anderson | d7bf67e | 2016-06-24 18:18:06 -0700 | [diff] [blame] | 12 | } |
| 13 | } |
| 14 | |
| 15 | repositories { |
| 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 Mastrangelo | 17b9016 | 2017-04-11 14:51:39 -0700 | [diff] [blame] | 25 | def grpcVersion = '1.4.0-SNAPSHOT' // CURRENT_GRPC_VERSION |
Eric Anderson | d7bf67e | 2016-06-24 18:18:06 -0700 | [diff] [blame] | 26 | |
| 27 | dependencies { |
| 28 | compile "io.grpc:grpc-netty:${grpcVersion}" |
| 29 | compile "io.grpc:grpc-protobuf:${grpcVersion}" |
| 30 | compile "io.grpc:grpc-stub:${grpcVersion}" |
ZHANG Dapeng | 7306df4 | 2016-11-15 14:15:55 -0800 | [diff] [blame] | 31 | |
| 32 | testCompile "junit:junit:4.11" |
| 33 | testCompile "org.mockito:mockito-core:1.9.5" |
Eric Anderson | d7bf67e | 2016-06-24 18:18:06 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | protobuf { |
| 37 | protoc { |
Carl Mastrangelo | b0323ac | 2017-02-07 09:47:15 -0800 | [diff] [blame] | 38 | artifact = 'com.google.protobuf:protoc:3.2.0' |
Eric Anderson | d7bf67e | 2016-06-24 18:18:06 -0700 | [diff] [blame] | 39 | } |
| 40 | plugins { |
| 41 | grpc { |
| 42 | artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" |
| 43 | } |
| 44 | } |
| 45 | generateProtoTasks { |
| 46 | all()*.plugins { |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame] | 47 | 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 Anderson | d7bf67e | 2016-06-24 18:18:06 -0700 | [diff] [blame] | 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | // Inform IntelliJ projects about the generated code. |
| 57 | apply plugin: 'idea' |
| 58 | |
| 59 | idea { |
| 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 Buchgraber | 246e8b5 | 2015-02-18 13:26:48 -0800 | [diff] [blame] | 69 | apply plugin: 'application' |
Jakob Buchgraber | 246e8b5 | 2015-02-18 13:26:48 -0800 | [diff] [blame] | 70 | |
zhangkun83 | da3c3f8 | 2015-03-11 18:03:31 -0700 | [diff] [blame] | 71 | startScripts.enabled = false |
| 72 | |
Eric Anderson | 1cf4cc8 | 2015-05-07 07:37:51 -0700 | [diff] [blame] | 73 | task routeGuideServer(type: CreateStartScripts) { |
Eric Anderson | d7bf67e | 2016-06-24 18:18:06 -0700 | [diff] [blame] | 74 | 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 Buchgraber | 246e8b5 | 2015-02-18 13:26:48 -0800 | [diff] [blame] | 78 | } |
| 79 | |
Eric Anderson | 1cf4cc8 | 2015-05-07 07:37:51 -0700 | [diff] [blame] | 80 | task routeGuideClient(type: CreateStartScripts) { |
Eric Anderson | d7bf67e | 2016-06-24 18:18:06 -0700 | [diff] [blame] | 81 | 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 Buchgraber | 246e8b5 | 2015-02-18 13:26:48 -0800 | [diff] [blame] | 85 | } |
nmittler | 87daf0e | 2015-02-25 08:42:10 -0800 | [diff] [blame] | 86 | |
Eric Anderson | 1cf4cc8 | 2015-05-07 07:37:51 -0700 | [diff] [blame] | 87 | task helloWorldServer(type: CreateStartScripts) { |
Eric Anderson | d7bf67e | 2016-06-24 18:18:06 -0700 | [diff] [blame] | 88 | 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 |
nmittler | 87daf0e | 2015-02-25 08:42:10 -0800 | [diff] [blame] | 92 | } |
| 93 | |
Eric Anderson | 1cf4cc8 | 2015-05-07 07:37:51 -0700 | [diff] [blame] | 94 | task helloWorldClient(type: CreateStartScripts) { |
Eric Anderson | d7bf67e | 2016-06-24 18:18:06 -0700 | [diff] [blame] | 95 | 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 Anderson | 1cf4cc8 | 2015-05-07 07:37:51 -0700 | [diff] [blame] | 99 | } |
| 100 | |
Carl Mastrangelo | 091749e | 2015-09-08 11:41:58 -0700 | [diff] [blame] | 101 | task compressingHelloWorldClient(type: CreateStartScripts) { |
Eric Anderson | d7bf67e | 2016-06-24 18:18:06 -0700 | [diff] [blame] | 102 | 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 Mastrangelo | 091749e | 2015-09-08 11:41:58 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Eric Anderson | d7bf67e | 2016-06-24 18:18:06 -0700 | [diff] [blame] | 108 | applicationDistribution.into('bin') { |
| 109 | from(routeGuideServer) |
| 110 | from(routeGuideClient) |
| 111 | from(helloWorldServer) |
| 112 | from(helloWorldClient) |
| 113 | from(compressingHelloWorldClient) |
| 114 | fileMode = 0755 |
Louis Ryan | a623445 | 2015-03-12 13:46:14 -0700 | [diff] [blame] | 115 | } |