|

How to make Eclipse aware of Gradle dependencies

Some time ago, I blogged about Gradle support in Eclipse. One feature I failed to spot was an automatic import of Gradle dependencies.

The pain point for me was that whenever I successfully built the project (in Eclipse using the Gradle plugin!) I was still getting compilation errors as the IDE wouldn’t automatically add the relevant JARs onto the build path. I would then go and add the JARs manually via the project Settings menu. Needless to say how painstakingly slow and error-prone that process was.

Turns out, Eclipse knows how to handle Gradle dependencies in a seamless way. To add all libraries your Gradle project depends on, in Eclipse:

Right-click on your project in the Package Explorer, choose Gradle and click on Refresh Gradle Project. Once the refresh is done all compilation errors should be gone.

Tested on the Mars Release (4.5.0), kudos to Peter Niederwieser for his answer on Stackoverflow.

Similar Posts