bazel: Support java_export by adding maven_coordinates to targets
- Dominant language
- Java
- Stars
- 12.1k
- Forks
- 4k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 37
Description
### 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
1. Create a java bazel project following the canonical example
2. Add a java_export rule, see below.
3. Run the publish rule: `bazel run --define "maven_repo=file://$HOME/.m2/repository" //export_test:export_test.publish`
4. 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
5. Observe that protobuf and grpc dependencies are omitted from the pom file
6. 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](https://github.com/grpc/grpc-java/commit/9d6f5322c21db5e7067833e46c58718cd8324f23#diff-5b010cebc220a1927b558a589a75b3b34b573d435b19f89d5783de7ea0a3f61d), seems to work fine.
Alternatively, perhaps someone could set the maven_coordinates tags so that java_export knows which artifacts to reference!
Contributor guide
Assessment
This issue has not been assessed yet.