Skip to content

When importing GRPC Java on bzlmod, we cannot control which version of guava is imported #11102

Closed
@hlawrence-cn

Description

@hlawrence-cn

What version of gRPC-Java are you using?

1.62.2 on bzlmod

What is your environment?

Mac in a bazel repo. Also reproducible in Linux.

What did you expect to see?

My application using the version of guava specified in our app at runtime.

What did you see instead?

My application being compiled against our specified version of guava... and run against guava-android from grpc-java at runtime.

Steps to reproduce the bug

Import guava-jre from rules_jvm
Use a non-android API, like com.google.common.collect.ImmutableSet.toImmutableSet
This works as expected

Import grpc-java via bzlmod
Use in app
com.google.common.collect.ImmutableSet.toImmutableSet calls fail at runtime with a java.lang.NoSuchMethodError

I can attempt to create a repo to repro if needed.

Perhaps separate targets could be used for android vs jre... though even in that case, we would be "stuck" with whatever version grpc-java uses. Something like netty-shaded could be used, but I'm sure you'd rather avoid shading. Some way to override dependencies in other repos within bzlmod could resolve... but I suspect that's complexity they'd rather not add. Not really sure what a sane solution is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions