grpc-java/compiler
David Burns 00649913b0
bazel: Use the `artifact` macro for loading maven deps
The recommended way to load dependencies from `rules_jvm_external`
is to make use of the `@maven` workspace, and the most readable
way of doing that is to use the `artifact` macro provides.

This removes the need to generate the "compat" namespaces, which
`rules_jvm_external` provided for backwards compatibility with
older releases. This change also sets things up for supporting
`bzlmod`: this requires all workspaces accessed by a library to
be named "up front" in the `MODULE.bazel` file. This way, the
only repo that needs to be exported is `@maven`, rather than the
current huge list.
2024-03-28 14:33:32 -07:00
..
src Start 1.64.0 development cycle (#11030) 2024-03-22 09:32:10 -07:00
BUILD.bazel bazel: Use the `artifact` macro for loading maven deps 2024-03-28 14:33:32 -07:00
README.md Bump Protobuf to 3.17.2 2021-06-07 11:20:48 -07:00
build.gradle compiler: Support up-to-date checking in golden tests 2024-02-26 10:03:13 -08:00
check-artifact.sh Fix aarch_64 macs not being able to build the compiler module. (#10516) 2023-08-23 14:58:11 -07:00

README.md

gRPC Java Codegen Plugin for Protobuf Compiler

This generates the Java interfaces out of the service definition from a .proto file. It works with the Protobuf Compiler (protoc).

Normally you don't need to compile the codegen by yourself, since pre-compiled binaries for common platforms are available on Maven Central:

  1. Navigate to https://mvnrepository.com/artifact/io.grpc/protoc-gen-grpc-java
  2. Click into a version
  3. Click "Files"

However, if the pre-compiled binaries are not compatible with your system, you may want to build your own codegen.

Compiling and testing the codegen

Set up your system as described in COMPILING.md.

Then change to the compiler directory:

$ cd $GRPC_JAVA_ROOT/compiler

To compile the plugin:

$ ../gradlew java_pluginExecutable

To test the plugin with the compiler:

$ ../gradlew test

You will see a PASS if the test succeeds.

To compile a proto file and generate Java interfaces out of the service definitions:

$ protoc --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \
  --grpc-java_out="$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"

To generate Java interfaces with protobuf lite:

$ protoc --plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \
  --grpc-java_out=lite:"$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"

Installing the codegen to Maven local repository

This will compile a codegen and put it under your ~/.m2/repository. This will make it available to any build tool that pulls codegens from Maven repositories.

$ ../gradlew publishToMavenLocal

Creating a release of gRPC Java

Please follow the instructions in RELEASING.md under the root directory for details on how to create a new release.