bazel: Support java_export by adding maven_coordinates to targets
- Lingua principale
- Java
- Stelle
- 12.1k
- Fork
- 4k
- Merge medio
- 2g 17h
- PR unite (30g)
- 37
Descrizione
### 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!
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Start with the java_export rule and the IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS workaround described in the issue, then reproduce with the provided bazel publish command. Inspect the generated POM and JAR; done means protobuf and gRPC appear as Maven dependencies rather than their classes being embedded in the artifact.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java
- Ambito
- build-system, release
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100