1

I have project xxxWeb using project xxxAPI. Both projects are sub project of a parent project. Project xxxAPI uses a third-party library jar jar1.jar, which has a class somepackage.ClassA. Project xxxAPI itself also has identical somepackage.ClassA that project xxxWeb intends to use.

However, Eclipse load somepackage.ClassA from jar1.jar instead, resulting in compilation error because jar1/somepackage/ClassA doesn't have the necessary fields like in xxxAPI/somepackage/ClassA.

In xxxWeb project classpath, Eclipse place xxxAPI project to the very end, which probably why the compiler pick jar1/somepackage/ClassA instead of xxxAPI/somepackage/ClassA.

This is not a problem in IntelliJ however.

Is there a cure for this?

The build script work fine, so I this is a question on Gradle's Eclipse plugin, and how to manipulate the generated classpath?

Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130
timpham
  • 556
  • 2
  • 7
  • 25

1 Answers1

0

This is a bug of gradle as of version 2.14.1. A workaround is to utilize the hook given by Eclipse Gradle plugin to remove the duplicated classpath entries

eclipse {
    classpath {
        file {
            whenMerged { cp ->
                cp.entries = cp.entries.unique{a,b -> a.path <=> b.path}
            }
        }
    }
}
timpham
  • 556
  • 2
  • 7
  • 25