bazel-contrib / bazel-contrib/rules_jvm_external
Cannot resolve conflicting class path bindings
- Dominant language
- Java
- Stars
- 373
- Forks
- 301
- Avg merge
- 7d 17h
- Merged PRs (30d)
- 3
Description
Aloha!
We are currently running into issues with conflicting class path bindings, for an application that's depending on both `ch.qos.logback:logback-classic` and `org.apache.avro:avro-tools`.
For example, we're seeing this:
```
SLF4J: Found binding in [jar:file:/app/maven_install/v1/https/artifactory/maven-release/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/app/maven_install/v1/https/artifactory/maven-release/org/apache/avro/avro-tools/1.8.2/avro-tools-1.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
```
The root cause is that both of these jars contain the `StaticLoggerBinding.class` from `slf4j`:
```
>_ jar -tf logback-classic-1.2.3.jar
META-INF/
META-INF/MANIFEST.MF
ch/
ch/qos/
ch/qos/logback/
ch/qos/logback/classic/
ch/qos/logback/classic/AsyncAppender.class
ch/qos/logback/classic/BasicConfigurator.class
ch/qos/logback/classic/ViewStatusMessagesServlet.class
... truncated ...
org/slf4j/impl/StaticLoggerBinder.class <---- Here!!!
org/slf4j/impl/StaticMarkerBinder.class
org/slf4j/impl/StaticMDCBinder.class
... truncated ...
```
```
>_ jar -tf avro-tools-1.8.2.jar
META-INF/MANIFEST.MF
META-INF/
META-INF/cddl-1.0.text
META-INF/cddl-1.1.text
META-INF/DEPENDENCIES
META-INF/LICENSE
META-INF/mpl-2.0.text
META-INF/NOTICE
org/
org/apache/
org/apache/avro/
org/apache/avro/tool/
org/apache/avro/tool/BinaryFragmentToJsonTool.class
org/apache/avro/tool/CatTool.class
org/apache/avro/tool/ConcatTool.class
... truncated ...
org/slf4j/
org/slf4j/impl/
org/slf4j/impl/Log4jLoggerAdapter.class
org/slf4j/impl/Log4jLoggerFactory.class
org/slf4j/impl/Log4jMDCAdapter.class
org/slf4j/impl/StaticLoggerBinder.class <---- Here!!!
org/slf4j/impl/StaticMarkerBinder.class
org/slf4j/impl/StaticMDCBinder.class
... truncated ...
```
That results in both of these being placed onto the class path.
Looking through the `rules_jvm_external` docs, we saw configuration options for us to exclude entire jars from being pulled in, but we did not see a method to exclude just a single component of a jar. Advice on this matter would be appreciated!
(If this issue is more appropriate to post in https://github.com/bazelbuild/rules_java, we can certainly do that too!)
Thanks in advance!
Contributor guide
Research direction
Start by reviewing the rules_jvm_external documentation and the dependency-resolution entry points it references; reproduce the conflict with the listed logback-classic and avro-tools artifacts. Done means the project has a supported, documented way to handle a single conflicting class without excluding an entire jar, with validation for this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100