grpc/grpc-java

bazel: Support java_export by adding maven_coordinates to targets

Open

#9.965 aberto em 20 de mar. de 2023

Ver no GitHub
 (4 comments) (0 reactions) (0 assignees)Java (3.742 forks)batch import
help wanted

Métricas do repositório

Stars
 (11.124 stars)
Métricas de merge de PR
 (Mesclagem média 23d 22h) (43 fundiu PRs em 30d)

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
  1. Observe that protobuf and grpc dependencies are omitted from the pom file
  2. 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!

Guia do colaborador