I finally found the problem.
The issue did was related to classpath as jeremyjjbrown suggested in his comment, but was related to the Eclipse-Gradle plugin and the way it imports projects.
How I solved the problem
- deleted the project in Eclipse
- went to terminal, in the project source folder
- typed
gradle cleanEclipse
- typed
gradle eclipse
in Eclipse, import the project following theImport
->Existing Projects into Workspace
That indeed solved the problem, but then I could not manage Gradle directly inside Eclipse (i.e. I could not right click
-> Gradle
-> Refresh All
) since the project did not have a Gradle nature. Converting it to a Gradle project made the original problem coming back. So, finally,
How I really solved the problem
Looking at my gradle.build
, you can see testCompile "org.jmock:jmock-junit4:2.6.0"
. jMock has a subtle problem: it brings junit-dep:4.4
with it. That dependency in Eclipse was causing the problem, inserting the related jar into the classpath. Changing the testCompile
line to
testCompile ("org.jmock:jmock-junit4:${jmockVersion}") {
exclude group:"junit"
}
really solved the problem.
I thank pbanfi who personally helped my debugging and solving the problem for real