How to exclude packages when depending on an uber jar

A dependencies that I’m relying has its JAR up on Maven, but not all of its transitive dependencies are available.

So I am resorting to depending on the JAR itself. Specifically, via runtimeOnly 'ai.h2o:mojo2-runtime:2.7.11.1@jar.

The JAR includes a conflicting org.slf4j.impl.SimpleLoggerFactory from a transitive dependency. I can’t seem to exclude the culprit org.slf4j module when depending on this uber JAR.

I would have hoped that the following would work, but alas no exclusions are happening.

runtimeOnly('ai.h2o:mojo2-runtime:2.7.11.1@jar') {
        exclude group: "org.slf4j", module: "slf4j-simple"
}

It seems exclusions don’t work when explicitly depending on uber jars? What’s the correct approach here?

Publishing a fat jar to a Maven repository actually is pretty much non-sense.
It is against the nature of a Maven repository where you have your jar and metadata that describes the dependencies you have so that a proper tool like Grale or Maven or Ivy could get them all.

But anyway, your exclude of course does nothing, what should it do.
By using @jar you already said you only want the jar and none of its dependencies.
That’s equal to excluding everything, so there is nothing more you could exclude.

There is no built-in means to exclude files from within a JAR as that is generally a horrible idea, as is depending on far jars - especially without shading - that could easily get you into trouble.
If you want to exclude files from the artifact, you need to use an artifact transform that does this.

A post was split to a new topic: Transitive strict dependency declaration ignored by Gradle

Please do not hijack foreign threads that are even not really related, but open a separate thread. This is a forum, not a chat. :wink: