grpc/grpc-java
在 GitHub 查看bazel: Support java_export by adding maven_coordinates to targets
Open
#9,965 创建于 2023年3月20日
help wanted
描述
What version of gRPC-Java are you using?
1.50.2
What is your environment?
OSX
What did you expect to see?
The pom file generated from a java_export when using GRPC includes GRPC dependencies rather than inlining them into the generate jar file.
What did you see instead?
The pom file does NOT include a grpc dependency. The generate jar includes directly grpc classes. For example: io/grpc/Attributes.java, io/grpc/util/AdvancedTlsX509KeyManager.java, io/grpc/stub/AbstractAsyncStub.java
Steps to reproduce the bug
- Create a java bazel project following the canonical example
- Add a java_export rule, see below.
- Run the publish rule:
bazel run --define "maven_repo=file://$HOME/.m2/repository" //export_test:export_test.publish - Examine the resulting pom file and artifact
- jar tf ~/.m2/repository/com/example/exporttest/0.0.1/exporttest-0.0.1-sources.jar|less
- less ~/m2/repository/com/example/exporttest/0.0.1/exporttest-0.0.1.pom
- Observe that protobuf and grpc dependencies are omitted from the pom file
- Observe that protobuf and grpc classes are in the jar file
java_export(
name = "export_test",
maven_coordinates = "com.example:exporttest:0.0.1",
runtime_deps = [
"//export_test_lib",
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:com_google_protobuf_protobuf_java_util",
"@maven//:io_grpc_grpc_api",
"@maven//:io_grpc_grpc_core",
"@maven//:io_grpc_grpc_protobuf",
"@maven//:io_grpc_grpc_stub",
],
)
Workaround
Simply removing IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS, added here, seems to work fine.
Alternatively, perhaps someone could set the maven_coordinates tags so that java_export knows which artifacts to reference!