bazel-contrib / bazel-contrib/rules_jvm_external
`override_targets` can create duplicate dependencies
- Dominant language
- Java
- Stars
- 373
- Forks
- 301
- Avg merge
- 7d 17h
- Merged PRs (30d)
- 3
Description
[Guice multibindings](https://github.com/google/guice/wiki/Multibindings) was added to Guice core in 4.2. Our repo only uses Guice 4.2+, so we'd like to point multibindings to guice:
```
override_targets = {
"com.google.inject.extensions:guice-multibindings": "@maven//:com_google_inject_guice"
}
```
For dependencies which depend on both guice and guice multibindings, for example [nifty-core](https://repo1.maven.org/maven2/com/facebook/nifty/nifty-core/0.23.0/nifty-core-0.23.0.pom), this results in a duplicate dependency in the generated rule:
```
jvm_import(
name = "com_facebook_nifty_nifty_core",
jars = [...],
srcjar = "...",
deps = [
":io_airlift_log",
":io_airlift_units",
":com_google_code_findbugs_annotations",
"@maven//:com_google_inject_guice",
":io_netty_netty",
":com_google_guava_guava",
":javax_inject_javax_inject",
":com_google_inject_guice",
],
tags = ["maven_coordinates=com.facebook.nifty:nifty-core:0.23.0"],
)
```
which fails with an error that looks like:
```
Label '@maven//:com_google_inject_guice' is duplicated in the 'deps' attribute of rule 'com_facebook_nifty_nifty_core'
```
Contributor guide
Research direction
Start by tracing how override_targets is processed when generating the jvm_import rule and its deps attribute. Reproduce the nifty-core example with both guice and guice-multibindings mapped to the same target, then verify the generated rule contains that target only once and no duplicate-label error occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100