grpc-java/compiler
Thomas Broyer 2ffc46d6fa Update net.ltgt.errorprone to 0.6 and enable Error Prone on JDK 10+ 2018-12-13 10:17:06 -08:00
..
src Start 1.18.0 development cycle 2018-11-19 14:49:35 -08:00
BUILD.bazel build: Add Bazel java_grpc_library rule 2017-06-22 13:06:49 -07:00
Dockerfile Upgrade to Protobuf 3.5.1 and Protoc 3.5.1-1. (#3921) 2018-01-05 16:40:20 -08:00
README.md compiler: update path to protoc plugin in README 2017-02-23 12:55:55 -08:00
build.gradle Update net.ltgt.errorprone to 0.6 and enable Error Prone on JDK 10+ 2018-12-13 10:17:06 -08:00
check-artifact.sh compiler: whitelist USER32.DLL. (#2455) 2016-11-28 17:45:11 -08:00

README.md

gRPC Java Codegen Plugin for Protobuf Compiler

This generates the Java interfaces out of the service definition from a .proto file. It works with the Protobuf Compiler (protoc).

Normally you don't need to compile the codegen by yourself, since pre-compiled binaries for common platforms are available on Maven Central. However, if the pre-compiled binaries are not compatible with your system, you may want to build your own codegen.

System requirement

  • Linux, Mac OS X with Clang, or Windows with MSYS2
  • Java 7 or up
  • Protobuf 3.0.0-beta-3 or up

Compiling and testing the codegen

Change to the compiler directory:

$ cd $GRPC_JAVA_ROOT/compiler

To compile the plugin:

$ ../gradlew java_pluginExecutable

To test the plugin with the compiler:

$ ../gradlew test

You will see a PASS if the test succeeds.

To compile a proto file and generate Java interfaces out of the service definitions:

$ protoc --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \
  --grpc-java_out="$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"

To generate Java interfaces with protobuf lite:

$ protoc --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \
  --grpc-java_out=lite:"$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"

To generate Java interfaces with protobuf nano:

$ protoc --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \
  --grpc-java_out=nano:"$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"

Installing the codegen to Maven local repository

This will compile a codegen and put it under your ~/.m2/repository. This will make it available to any build tool that pulls codegens from Maven repostiories.

$ ../gradlew install

Creating a release of GRPC Java

Please follow the instructions in RELEASING.md under the root directory for details on how to create a new release.