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