External jar contains old version of dependency

Hi,
we have a project where we use a proprietary jar as a dependency. Unfortunately that jar is a fat jar, that includes some dependencies that we also use in the project but with a much more recent version.

The problem is now, that while the IDEs (Eclipse and VSCode) use the version defined in the build.gradle files (and thus the code running as expected when launching it in the IDE), Gradle seems to be using the version bundled in the above-mentioned fat jar when compiling, resulting in compilation errors (mainly missing methods).

Is there any way to tell gradle to use the version defined in build.gradle instead of using whatever is bundled in the fat jar?

This is a matter of classpath ordering.
Gradle orders classpaths in the order they are defined in the build script.
So if you put that fat jar after the other dependencies, Gradle should not use the classes in the fat jar for ones that are duplicate.

But actually, if the classpath order in the IDE is different from what Gradle uses, this is a bug in the respective Gradle integration that you should report. Those should be usually behave the same.

To be super sure that the classpath ordering is irrelevant also later when running, I’d suggest to use an artifact transform that transforms exactly that jar and throws out the foreign classes from it, then it is only used as thin jar and everything should behave the same.