Search code examples
protocol-buffersgrpcbazel

How to generate jar file from srcjar artifact?


I have some proto files and I am using bazel to build them. I am using proto-rules-grpc to generate the BUILD file for bazel. Then I'm running bazel build command. But the final artefact is in .srcjar.

This also what the rule says and I quote:

Generates a Java protobuf and gRPC srcjar file

But I want the final artefact in .jar format. Whereas .srcjar only contains the .java file.

The manual process I can think of is to extract the raw java file from the .srcjar artefact and then use them to create the .jar file. But this is a bit annoying to do all this manually.

Is there any way to do it without involving the manual process?


Solution

  • Use java_grpc_library.

    java_grpc_compile produces a .srcjar. java_grpc_library produces a .jar.