Gradle is a great java build automation tool, you can do everything from the command line, but an IDE surely helps a lot. An IDE plugin allows you interactive with Gradle in GUI interface, edit build script and Java source file in one place, execute task and run build by pressing a button. This post shows you how to let Gradle project works in Eclipse, how to import Gradle project into Eclipse and build it in Eclipse.
STEP 1. Install Gradle plugin for Eclipse
The best way to use Gradle inside Eclipse is install the Gradle plugin, this plugin add new options to Create Project, Import Project and project popup menus, allows you to create, import , debug and build Gradle Project in Eclipse.
Select Help - Install New Softare... and paste the following url
One problem you may run into is wait too long when downloading from dist.springsource.com. The other way is to install Gradle plugin from Eclipse Marketplace. Select Help - Eclipse Marketplace and search for "Gradle", find GradleIDE and install.
After that, you will see Gradle Project option in New Project wizard:
STEP 2. Import Gradle project
After installed Eclipse Gradle plugin, import gradle project is easy, let's see an example, checkout the org hibernate project from github
git clone https://github.com/hibernate/hibernate-orm.git
It's a Gradle project, to import the Gradle project into Eclipse, select File - Import and choose Gradle Project, select the root folder of your project on the import dialogue box.
Click Build Model will try to verify the project, if the project and build.gradle is valid, a list of selectable projects is displayed, if it's multi projects, two or more items will be displayed. You can import the Gradle project you wanted as Eclipse project.
STEP 3. Build in Eclipse
On first running, Gradle will get all the necessary dependencies, it may takes a while.
After importing, you can build the project, there are two methods to build, select Run As - Gradle Build, and select tasks to build,
Or Gradle - Task Quick Launcher