Eclipse classpath: 2 different configurations with 2 different versions of the dependency. How to keep only one version in .classpath

In order to have the good classpath in eclipse, I use the eclipse plugin ( that merges the classpaths of the different configurations.
In my case, the merge classpaths are from : testRuntime, compileClasspath, testCompileClasspath, runCompileClasspath.

My problem is that sometimes in 2 different configurations (usually compile and another one), I have the same dependency but with a different version. At the end, I have the duplication in the file “.classpath”. For exemple commons-io in version 2.4 AND in 2.5.
What I want is to keep the version needed for the compile configuration.

As I understood, I can modify/filter the classpath generated in the function “whenMerged” of the plugin. The fonction provides as an argument the merged classpath. I wanted to find the dependency duplications in it and then remove the wrong one. Unfortunatly I have no idea which one is from the compile configuration and which one is from another configuration. The dependencies given in the classpath are of type and I can’t find this information in it.

Do you have any suggestion to do what I want to do?

Thanks for you help.


You could check compileClasspath.contains(library.library.file). Alternatively you could use the ResolutionStrategy on your Configurations to make sure everyone gets the same version of commons-io.

In the mid term, we’ll probably want to introduce an eclipseClasspath Configuration which extends from the other ones and does conflict resolution between them, so you no longer end up with duplicates.

1 Like

compileClasspath.contains(library.library.file) does the work. Thank you !