gRPC + Gradle project template
MIT License
This is a basic project template for people wanting to use the Gradle build tool with Google's gRPC framework.
Here I've implemented a client and server based on the Protocol
Buffers definition file in
src/main/proto/auth.proto
.
To build the client and server:
$ ./gradlew installDist
To run the server:
$ build/install/grpc-gradle/bin/auth-server
To run the client you must specify a username and password as args 0 and 1:
$ build/install/grpc-gradle/bin/auth-client {username} {password}
If you don't specify tonydanza
as the username and whostheboss
as the
password your authenticate request will fail!
When you run gradle build
and analogous commands, Gradle will place all
generated Java files in src/generated/main/{grpc,java}
.
The executables for the client and server are defined in
src/main/resources/executables.gradle
. The Gradle configuration for gRPC and
Protocol Buffers are found in src/main/resources/grpc.gradle
.
I did all of this using Gradle 2.10.0 version 0.12.0 of the Java gRPC library.
The example client and server are heavily based on the examples on the grpc-java GitHub page and you can piece together how to do all of this stuff. But it's a pain in the ass and it took me a while to work out a bunch of kinks, so I figured I'd share it with the world.