I have a gradle project. I am getting 2 versions of a library through transitive dependency. These 2 show up on my Project and External Dependencies. May be some downstream library has forced an older version.
ImageClient-18.0.jar
ImageClient-18.2.jar
The problem I am facing is, when I am running my application and I do below
MyClass.class.getClassLoader().getResources("image.xml");
I am getting 2 copies of this file. One contained in each of the above jar.
I thought, as a Gradle project, Eclipse should add only the latest to my classpath.
The exact same code in intelliJ is returning image.xml
in 18.2 jar. Even IntelliJ has both jars in its External Libraries but the runtime resolves to the latest.
NOTE: The problem goes away if I add below to my build.gradle in Eclipse.
force "com.foo.bar:ImageClient:18.2"
However, the project runs fine both on IntelliJ and as a tarball, deployed on Jetty, without any change. So I don’t want to add the above line to my build.gradle. I want Eclipse to resolve a single jar in runtime. Is there a way out?