1*e07d83d3SAndroid Build Coastguard WorkergRPC Java Codegen Plugin for Protobuf Compiler 2*e07d83d3SAndroid Build Coastguard Worker============================================== 3*e07d83d3SAndroid Build Coastguard Worker 4*e07d83d3SAndroid Build Coastguard WorkerThis generates the Java interfaces out of the service definition from a 5*e07d83d3SAndroid Build Coastguard Worker`.proto` file. It works with the Protobuf Compiler (``protoc``). 6*e07d83d3SAndroid Build Coastguard Worker 7*e07d83d3SAndroid Build Coastguard WorkerNormally you don't need to compile the codegen by yourself, since pre-compiled 8*e07d83d3SAndroid Build Coastguard Workerbinaries for common platforms are available on Maven Central: 9*e07d83d3SAndroid Build Coastguard Worker 10*e07d83d3SAndroid Build Coastguard Worker1. Navigate to https://mvnrepository.com/artifact/io.grpc/protoc-gen-grpc-java 11*e07d83d3SAndroid Build Coastguard Worker2. Click into a version 12*e07d83d3SAndroid Build Coastguard Worker3. Click "Files" 13*e07d83d3SAndroid Build Coastguard Worker 14*e07d83d3SAndroid Build Coastguard WorkerHowever, if the pre-compiled binaries are not compatible with your system, 15*e07d83d3SAndroid Build Coastguard Workeryou may want to build your own codegen. 16*e07d83d3SAndroid Build Coastguard Worker 17*e07d83d3SAndroid Build Coastguard Worker## Compiling and testing the codegen 18*e07d83d3SAndroid Build Coastguard Worker 19*e07d83d3SAndroid Build Coastguard WorkerSet up your system as described in [COMPILING.md](../COMPILING.md). 20*e07d83d3SAndroid Build Coastguard Worker 21*e07d83d3SAndroid Build Coastguard WorkerThen change to the `compiler` directory: 22*e07d83d3SAndroid Build Coastguard Worker``` 23*e07d83d3SAndroid Build Coastguard Worker$ cd $GRPC_JAVA_ROOT/compiler 24*e07d83d3SAndroid Build Coastguard Worker``` 25*e07d83d3SAndroid Build Coastguard Worker 26*e07d83d3SAndroid Build Coastguard WorkerTo compile the plugin: 27*e07d83d3SAndroid Build Coastguard Worker``` 28*e07d83d3SAndroid Build Coastguard Worker$ ../gradlew java_pluginExecutable 29*e07d83d3SAndroid Build Coastguard Worker``` 30*e07d83d3SAndroid Build Coastguard Worker 31*e07d83d3SAndroid Build Coastguard WorkerTo test the plugin with the compiler: 32*e07d83d3SAndroid Build Coastguard Worker``` 33*e07d83d3SAndroid Build Coastguard Worker$ ../gradlew test 34*e07d83d3SAndroid Build Coastguard Worker``` 35*e07d83d3SAndroid Build Coastguard WorkerYou will see a `PASS` if the test succeeds. 36*e07d83d3SAndroid Build Coastguard Worker 37*e07d83d3SAndroid Build Coastguard WorkerTo compile a proto file and generate Java interfaces out of the service definitions: 38*e07d83d3SAndroid Build Coastguard Worker``` 39*e07d83d3SAndroid Build Coastguard Worker$ protoc --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \ 40*e07d83d3SAndroid Build Coastguard Worker --grpc-java_out="$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE" 41*e07d83d3SAndroid Build Coastguard Worker``` 42*e07d83d3SAndroid Build Coastguard WorkerTo generate Java interfaces with protobuf lite: 43*e07d83d3SAndroid Build Coastguard Worker``` 44*e07d83d3SAndroid Build Coastguard Worker$ protoc --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \ 45*e07d83d3SAndroid Build Coastguard Worker --grpc-java_out=lite:"$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE" 46*e07d83d3SAndroid Build Coastguard Worker``` 47*e07d83d3SAndroid Build Coastguard Worker 48*e07d83d3SAndroid Build Coastguard Worker## Installing the codegen to Maven local repository 49*e07d83d3SAndroid Build Coastguard WorkerThis will compile a codegen and put it under your ``~/.m2/repository``. This 50*e07d83d3SAndroid Build Coastguard Workerwill make it available to any build tool that pulls codegens from Maven 51*e07d83d3SAndroid Build Coastguard Workerrepositories. 52*e07d83d3SAndroid Build Coastguard Worker``` 53*e07d83d3SAndroid Build Coastguard Worker$ ../gradlew publishToMavenLocal 54*e07d83d3SAndroid Build Coastguard Worker``` 55*e07d83d3SAndroid Build Coastguard Worker 56*e07d83d3SAndroid Build Coastguard Worker## Creating a release of gRPC Java 57*e07d83d3SAndroid Build Coastguard WorkerPlease follow the instructions in ``RELEASING.md`` under the root directory for 58*e07d83d3SAndroid Build Coastguard Workerdetails on how to create a new release. 59