grpc-java/compiler
Eric Anderson f3f4ed4ef3 Upgrade to Gradle 8.2.1 and upgrade plugins
Most changes are migrating from conventions to the equivalent
extensions. JMH, AppEngine, and Jib plugins trigger future compatibility
warnings with `--warning-mode all`.

The movement of configurations was to allow sourceSets to create the
configurations and then we just configure them. When configurations were
before sourceSets, we'd implicitly create the configuration.

The examples were _not_ updated to the newer Gradle, although the
non-Android examples work with the newer Gradle. The Android examples
use an older Android Gradle Plugin which will need to be upgraded first.
https://github.com/grpc/grpc-java/issues/10445
2023-08-02 13:29:44 -07:00
..
src Bump version (#10378) 2023-07-13 13:06:21 -07:00
BUILD.bazel bazel: Add compatibility for --incompatible_load_cc_rules_from_bzl 2019-10-16 13:29:19 -07:00
README.md Bump Protobuf to 3.17.2 2021-06-07 11:20:48 -07:00
build.gradle Upgrade to Gradle 8.2.1 and upgrade plugins 2023-08-02 13:29:44 -07:00
check-artifact.sh Add support for cross-compiling for s390x platform (#9455) 2023-03-23 13:21:31 -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.