README.md
1 gRPC Java Codegen Plugin for Protobuf Compiler
2 ==============================================
3
4 This generates the Java interfaces out of the service definition from a
5 `.proto` file. It works with the Protobuf Compiler (``protoc``).
6
7 Normally you don't need to compile the codegen by yourself, since pre-compiled
8 binaries for common platforms are available on Maven Central. However, if the
9 pre-compiled binaries are not compatible with your system, you may want to
10 build your own codegen.
11
12 ## System requirement
13
14 * Linux, Mac OS X with Clang, or Windows with MSYS2
15 * Java 7 or up
16 * [Protobuf](https://github.com/google/protobuf) 3.0.0-beta-3 or up
17
18 ## Compiling and testing the codegen
19 Change to the `compiler` directory:
20 ```
21 $ cd $GRPC_JAVA_ROOT/compiler
22 ```
23
24 To compile the plugin:
25 ```
26 $ ../gradlew java_pluginExecutable
27 ```
28
29 To test the plugin with the compiler:
30 ```
31 $ ../gradlew test
32 ```
33 You will see a `PASS` if the test succeeds.
34
35 To compile a proto file and generate Java interfaces out of the service definitions:
36 ```
37 $ protoc --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \
38 --grpc-java_out="$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"
39 ```
40 To generate Java interfaces with protobuf lite:
41 ```
42 $ protoc --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \
43 --grpc-java_out=lite:"$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"
44 ```
45 To generate Java interfaces with protobuf nano:
46 ```
47 $ protoc --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \
48 --grpc-java_out=nano:"$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"
49 ```
50
51 ## Installing the codegen to Maven local repository
52 This will compile a codegen and put it under your ``~/.m2/repository``. This
53 will make it available to any build tool that pulls codegens from Maven
54 repostiories.
55 ```
56 $ ../gradlew install
57 ```
58
59 ## Creating a release of GRPC Java
60 Please follow the instructions in ``RELEASING.md`` under the root directory for
61 details on how to create a new release.
62