Ideally, you should fix the dependencies in your projects so that you have exactly the right set of boxes on the way to the classes. See how to eliminate dependencies in the Dependency Guide chapter of the Gradle documentation.
If you still want to change the classpath entries for eclipse, here is one possible solution.
You can tinker with a .classpath file generated using an eclipse task in Gradle using the following:
eclipse.classpath.file { withXml {
Take a look at the groovy.util.Node methods that you can use to view / modify the XML node.
Note that you will most likely not have any control over the sort order of the classes that is executed when you run the distribution of the packaged application in the JVM, which will return you to the square at runtime when the application really starts.
Therefore, the best solution is to find out the source of the jar dependency that you donβt want in your path to the classes and eliminate it from there, instead of relying on ordering the classes, which is risky and unreliable.
source share