Open friendly-pineapple opened 4 years ago
Hi - I also experienced this issue with multiple bindings found slf4j
. Have you tried using the override targets
feature:
override_targets
is probably the way to go, using a genrule
pipeline depending on the downloaded logback-classic or avro jar to strip out a particular class file. I don't know of a particular mechanism in the Java ruleset to strip out a particular classfile from a jar, though that would be helpful here.
hey @friendly-pineapple did this particular issue arise at build time or runtime for you? Reason I ask is because my project that depends on slf4j
built successfully, but had issues at runtime
We have the similar experience -- this happens at runtime for us.
A bit of a tangent, but this is a common and tedious problem for java Spring Boot applications. Spring Boot apps tend to aggregate a large number of deps and so class version conflicts have been more common than we expected. I don't think much of it is general purpose, but just for ideas here we have a set of strategies for dealing with this when using the Spring Boot rule: Detecting, Excluding and Suppressing Unwanted Classes
Can you workaround this by adjusting the classpath order so you load the class you want first?
If you still want to go the route of manipulating a third party jar you could just build a version of the jar without the classes and use that? Or if you want to do this with a rule you could probably use jarjar to process the jar and remove classes you don't want.
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
andorg.apache.avro:avro-tools
.For example, we're seeing this:
The root cause is that both of these jars contain the
StaticLoggerBinding.class
fromslf4j
: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!