blob: 10af9f0b28ae35a5cd6ec9da45d9656c5cb1c1a7 [file] [log] [blame] [view]
zhangkun83da3c3f82015-03-11 18:03:31 -07001gRPC Java Codegen Plugin for Protobuf Compiler
zhangkun83d54a4632015-01-26 10:53:17 -08002==============================================
3
zhangkun83da3c3f82015-03-11 18:03:31 -07004This generates the Java interfaces out of the service definition from a
5`.proto` file. It works with the Protobuf Compiler (``protoc``).
zhangkun83d54a4632015-01-26 10:53:17 -08006
zhangkun83da3c3f82015-03-11 18:03:31 -07007Normally you don't need to compile the codegen by yourself, since pre-compiled
8binaries for common platforms are available on Maven Central. However, if the
9pre-compiled binaries are not compatible with your system, you may want to
10build your own codegen.
zhangkun83d54a4632015-01-26 10:53:17 -080011
zhangkun83da3c3f82015-03-11 18:03:31 -070012## System requirement
zhangkun83d54a4632015-01-26 10:53:17 -080013
zhangkun83da3c3f82015-03-11 18:03:31 -070014* Linux, Mac OS X with Clang, or Windows with MSYS2
15* Java 7 or up
Kun Zhanga2511712015-06-05 14:55:26 -070016* [Protobuf](https://github.com/google/protobuf) 3.0.0-alpha-3 or up
zhangkun83da3c3f82015-03-11 18:03:31 -070017
18## Compiling and testing the codegen
zhangkun83d54a4632015-01-26 10:53:17 -080019Change to the `compiler` directory:
20```
21$ cd $GRPC_JAVA_ROOT/compiler
22```
23
24To compile the plugin:
25```
Kun Zhang221c5342015-04-29 18:16:15 -070026$ ../gradlew java_pluginExecutable
zhangkun83d54a4632015-01-26 10:53:17 -080027```
28
29To test the plugin with the compiler:
30```
zhangkun83da3c3f82015-03-11 18:03:31 -070031$ ../gradlew test
zhangkun83d54a4632015-01-26 10:53:17 -080032```
33You will see a `PASS` if the test succeeds.
34
35To compile a proto file and generate Java interfaces out of the service definitions:
36```
Kun Zhang221c5342015-04-29 18:16:15 -070037$ protoc --plugin=protoc-gen-java_rpc=build/binaries/java_pluginExecutable/protoc-gen-grpc-java \
zhangkun83d54a4632015-01-26 10:53:17 -080038 --java_rpc_out="$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"
39```
Xiao Hang6f0b21e2015-02-26 11:19:59 -080040To generate Java interfaces with protobuf nano:
41```
Kun Zhang221c5342015-04-29 18:16:15 -070042$ protoc --plugin=protoc-gen-java_rpc=build/binaries/java_pluginExecutable/protoc-gen-grpc-java \
Xiao Hang6f0b21e2015-02-26 11:19:59 -080043 --java_rpc_out=nano=true:"$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"
44```
zhangkun83da3c3f82015-03-11 18:03:31 -070045
46## Installing the codegen to Maven local repository
47This will compile a codegen and put it under your ``~/.m2/repository``. This
48will make it available to any build tool that pulls codegens from Maven
49repostiories.
50```
51$ ../gradlew install
52```
53
nmittler483738e2015-06-08 14:32:37 -070054## Creating a release of GRPC Java
55Please follow the instructions in ``RELEASING.md`` under the root directory for
56details on how to create a new release.