Launching Gradle builds from Eclipse

We're looking at converting our Ant build to Gradle.

In regards to integration with Eclipse, we are looking for (conceptually) equivalent functionality for launching builds from the IDE. Eclipse provides a nice Ant view for invoking Ant targets.

There is an Eclipse plugin for launching Gradle builds (, but this seems to require users to jump through hoops to invoke different targets (edit the launch configuration, etc.).

How are others using Gradle from inside Eclipse?


The short answer is that we do not invoke gradle scripts from Eclipse.

I believe this site outlines where this work is at the moment and it does not seem to be much right now.

I am a bit curious what kind of tasks you want to run from Eclipse. Why not run tasks from the command line?

This is kind of an old post, but the SpringSource STS team has released a plugin:

Installation instructions can be found here:

My experience has been pretty positive with it so far. For straight-up Java projects it works quite well. I am having some issues generating correct war files through Eclipse, while using the Gradle plugin, but gradle itself does it wonderfully. I am relatively new to gradle and the plugin though, so it could be something that I am missing.

Interim work-around more palatable to those with command-line phobia.

From Eclipse, use pulldown menu Run / External Tools / External Tools Configurations...

Select "Program" in left navigator panel then click the "New launch configuration" button in the tool bar (first button in my tool bar).

With Main tab selected, fill out the following fields:

  1. Name: (above the tabs) to "Gradle" (or whatever name you want for the launcher).
  2. Location: Use "Browse File System..." button to navigate to your "gradle.bat" or "gradlew.bat" to run.
  3. Working Directory: Use "Browse Workspace..." button to select directory with the "build.gradle" file for the desired project.
  4. Arguments: Enter "--gui"

Add to Arguments: the switch "-b filename.gradle" if you use a Gradle build file other than "build.gradle".

After this, your developers can use the Run / External Tools or tool bar button to launch the Gradle Gui. They can do this and close it after each use, or (to avoid startup lag), minimize it when not in use.

I know this is an old question, but I still do not think it is possible to have Eclipse run a gradle build for you. The Spring Gradle plugin is a great start, if you use that, you can define an external tool builder to run gradle when you want. If you have lots of projects and all are being built with gradle, you can even have gradle add the capability to your eclipse projects for you. While this can be cleaned up, you can add something like this to your gradle build file:

apply plugin: 'eclipse'

eclipse {
    project {
        // Store a copy of the desired Gradle_Builder.launch file in a top-level 'master'
        //    directory.  Then this code searches for it, and by copying it, 
        //    adds the launch file to the specifc project that will run gradle
        String launchFileNameOrig = '.externalToolBuilders/Gradle_Builder.launch'
        String launchFileName = launchFileNameOrig
        File launchFile = file(launchFileName)
        boolean needToCopy = false
        while (!launchFile.exists()) {
            launchFileName = '../' + launchFileName
            launchFile = file(launchFileName)
            needToCopy = true
        if (needToCopy) {
             copy {
                from (launchFile)
                into '.externalToolBuilders'

        buildCommand 'org.eclipse.ui.externaltools.ExternalToolBuilder', LaunchConfigHandle: '<project>/'+launchFileNameOrig
        file {
            // when they made the "buildCommand" it looks like they left off 'triggers', so parse the XML until
            // the right place is found, then insert it.
            withXml {
                def projectNode = it.asNode()
                projectNode.iterator().each { subNode ->
                    String subNodeText = '' + subNode
                    if (subNodeText.startsWith('buildSpec')) {
                        subNode.iterator().each { buildCmd ->
                            String nameNode = buildCmd?.name
                            if (nameNode.contains('ExternalToolBuilder')) {
                                buildCmd.appendNode('triggers', 'full')

This is the content of the file stored at the top of the directory hierarchy under: ./.externalToolBuilders/Gradle_Builder.launch. As defined here, this will only run after a "clean" [Gradle is more expensive time-wise than the native Java Builder, so continue to use that for auto-building]. Note: the file contents below also assumes that you are using "git" and the gradle wrapper. You see this on the ATTR_LOCATION value. Adjust as needed. One nice thing about this approach though is that you can have the gradle wrapper be any version of gradle you want, and then eclipse will use that version when it runs!

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${git_dir}/../gradlew"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="assemble"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${project_loc}"/>

You can create a custom launcher from eclipse which would invoke your Gradle build.

You can use the Gradle Eclipse plugin like gradle eclipse to generate an Eclipse project from the gradle project. It adds a lot of targets to the generated Eclipse projects and is highly customizable.

As ever, you are better off with IDEA. Support has been around since 2009

and even fuller support is available now via the EAP (free to use!)

There is also Enide Gradle that can be used with or without Gradle IDE by Pivotal. In Gradle, Maven or CDT(C++) project.

As separate plugin, it can have different configuration for Gradle version and Java version to use

This, Gradle IDE Pack are within Enide

The current answer to this question should be, Use Gradle's own Buildship plugin:

This is supported and developed by the Gradle team and will be continuously improved in the future. It can also handle older versions (with functionality based on Gradle version availability).

Need Your Help

How do you prevent the Visual Studio designer auto-generating columns in a DataGridView?

c# .net winforms visual-studio-2008 datagridview

I generate all my columns in a subclassed DataGridView programmatically. However Visual Studio 2008 keeps reading my constructor class (which populates a DataTable with empty content and binds it t...

what am i doing wrong with these classes and objects

python class object

Write a program to store student details in a class. The information should include a

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.