Can't run JUnit test with buildship plugin


I’m using Gradle Buildship plugin (1.0.20) with Eclipse (4.6) and Gradle 2.1 (yes, unfortunately I can’t use newer version) and Java 8.
I have a such project structure:

  • service
    • service-api
    • service-impl

“service-api” has some JARs as compile dependencies.
“service-impl” has: compile project(":service-api")

Also sevice-impl has some JUnit tests. There is no compilation errors in Eclipse in src and tests. But when I go to
Run -> JUnit test
I’m facing with NoClassDefFoundError (about classes that are dependencies from service-api).
But everything is OK from console and from STS plugin.

Could you help me? Any ideas?


Hi Eugen,

Looks like this is a bug in Buildship: the runtime classpath was restricted based on the assumption that each Eclipse project has all the dependencies assigned via the Gradle classpath container (a.k.a the entries under Project and External Dependencies in the Eclipse UI). Now, this is only true for Gradle versions >= 2.5.

I opened a Bugzilla entry for the problem, feel free to subscribe to it.


Could I just jump in on this discussion. I seem to be having a similar problem. I am using Gradle Buildship plugin (1.0.20) with Eclipse (4.6) and Gradle 2.10, so greater than the 2.5 mentioned, but have the same issue. If I add the projects manually to the build path then its all fine, but without the junit tests wont run. I have checked that the projects exist in the Gradle classpath container.

Any ideas for this one?


Unfortunately I can’t reproduce your issue. For me the problem only happens when using Gradle version 2.4 or earlier. I can analyse your use case though if you could create a sample project exhibiting your problem.

@steve and @evser: We’ve added a fix for this issue. We are planning to include it in the next bugfix release which will be published next week. If you want you can test it with the latest snapshot:
Please let us know if it resolves your problem.

@donat Seems that everything works great! Thank you!

Excellent, thanks for the feedback!