blob: d09a70be81ad518edc83699f03450ee8ef9187d4 [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 Zhange2ed2e82016-01-27 08:26:19 -080016* [Protobuf](https://github.com/google/protobuf) 3.0.0-beta-2 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```
Eric Anderson74490d52015-06-24 08:41:43 -070037$ protoc --plugin=protoc-gen-grpc-java=build/binaries/java_pluginExecutable/protoc-gen-grpc-java \
38 --grpc-java_out="$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"
zhangkun83d54a4632015-01-26 10:53:17 -080039```
Xiao Hang6f0b21e2015-02-26 11:19:59 -080040To generate Java interfaces with protobuf nano:
41```
Eric Anderson74490d52015-06-24 08:41:43 -070042$ protoc --plugin=protoc-gen-grpc-java=build/binaries/java_pluginExecutable/protoc-gen-grpc-java \
Eric Anderson0a01b3c2016-03-29 16:16:21 -070043 --grpc-java_out=nano:"$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"
Xiao Hang6f0b21e2015-02-26 11:19:59 -080044```
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.