Better Gradle Support in IntelliJ IDEA 12.1

Good news for all who use Gradle in their projects. The newest update of IntelliJ IDEA brings new features and enhancements for the Gradle integration.

Now IntelliJ IDEA provides you additional configuration settings:

  • Use gradle wrapper — The IDE automatically detects if the linked gradle project is wrapper-aware and uses it for refreshing the project and running tasks;
  • Use auto-import — Every project structure change is automatically picked up by the IDE on Gradle project refresh (e.g. when a new library is added/removed at build.gradle, it’s added/removed at the IDE as well). Note, that user-defined project changes are not automatically overwritten. E.g. when a user manually adds a library dependency to a module it’s not automatically removed during the auto-import.
  • Service directory path — Allows to specify a location where Gradle stores downloaded library binaries. Useful for Windows’ users who may want to tune their anti-virus software.

Additionally to the new settings now you can use the new actions for managing Gradle project.

Now it’s possible to remove IDE’s local project entities easily from the Gradle tool window.

The outdated libraries are represented now as a single node. Before this change such libraries used to appear separately in ‘gradle-local’ and ‘ide-local’ nodes.

The next action allows you resolving the conflicts by applying Gradle’s values.

And the final new feature for Gradle in IntelliJ IDEA 12.1 is managing tasks. The list with tasks defined in the project is available on a new tab in Gradle tool window. With this new tab you can see recently executed tasks and run any of them by a double click or through the context menu.

Please feel free to share your feedback at our forum and report any found issues to the issue tracker.

Develop with pleasure!

This entry was posted in New Features and tagged , , . Bookmark the permalink.

35 Responses to Better Gradle Support in IntelliJ IDEA 12.1

  1. marco says:

    Hi Denis,
    regarding the auto-import: Is it a “full” auto-import? I still have to hit “refresh” upon changing dependencies in my build.gradle, so it’s not like the maven “change a tag in the xml and it gets imported automatically”-support, or am I doing something wrong? :)


  2. Denis.Zhdanov says:

    Hi Marco,

    Yes, auto-import is performed on refresh now. The reason is quite simple – we use gradle api for parsing project info and it has a significant restriction: when current project structure is requested for invalid build.gradle file (which is rather often invalid when you’re actively editing it), the api performs massive output to stdout/stderr which can’t be suppressed. I created a ticket at gradle tracker, so, feel free to watch/vote it up –

  3. Rich says:

    Is there any plan to make the Tasks area muti-project aware?

  4. Andrey says:

    Hi Denis,
    Could auto-refresh be done similar Eclipse Gradle plugin? They have automatic refresh with delay. Have a look here:
    I know it is a bit different in Eclipse, as they don’t have auto-save. But it can be done with JetGradle, just don’t call auto-refresh if the syntax in file is invalid.

  5. Denis.Zhdanov says:

    Hi Andrey,

    ‘just don’t call auto-refresh if the syntax in file is invalid’ – how do you expect us to understand if the script is valid?


  6. The J says:

    Loving the new gradle integration! One thing that would be great:

    My projects have a lot of modules. The “.iml” files are getting generated into the root directory, which is spammy. It’d be swell if they could be generated into their respective module roots, or even better, into a directory of my choosing. I’d probably move them all under .idea/modules, out of the way.

  7. Thomas H says:

    @Denis Zhdanov
    ‘how do you expect us to understand if the script is valid?’
    Given your previous posting about the gradle tooling api you could trigger a parse of the build file and check for some of the additional massive output to stdout/stderr.
    If something of the additional output that is dumped for invalid build.gradle files is present do not update the intellij settings at all. Instead mark the build file as in error.

  8. Denis.Zhdanov says:

    Thanks, glad to hear.

    Regarding *.iml location – that is already addressed by Now you can choose from ‘keep all *.iml at project dir’ and ‘keep *.iml at module content root’ during importing from gradle.

  9. The J says:

    Ah, missed that. Very nice!

  10. Denis.Zhdanov says:

    @Thomas: there are two problems here:
    1. Gradle script has invalid state most of the time during editing;
    2. Gradle api output is rather verbose;
    IJ logs would be full of gradle api output every time a user edits gradle script then and that is unacceptable for us.

  11. Rogelio says:

    I’m having a problem with my project structure. I’ve got a (legacy) java module that is build with ant, added a second module and setup a gradle build for it. Now the first module disappears every time that jetgradle refreshes. I’ve got that temporarily patched by adding gradle build and settings on a common ancestor directory. Now I tried to add a ruby module to get my cucumber going and get the same problem, but this time adding the ruby module to the gradle settings feels like going to far, plus it may (may not, have to verify) mess up some of the ruby support.

  12. Denis.Zhdanov says:

    Hi Regelio,

    Our gradle integration now assumes that the whole project is managed by gradle, that’s why it removes modules which doesn’t have gradle counterparty if auto-import is turned on. That is going to be fixed at IJ v.13 (i.e. it will be possible to have a project where not all modules are backed by gradle). Current workaround – turn off auto-import (project settings | gradle | use auto-import) and manage the project explicitly via JetGradle tool window.


  13. Ryan says:

    I’m having a tough time getting IDEA to use the Gradle wrapper. If I don’t set a Gradle Home location IDEA complains “Gradle is not configured. Do you want to configure it?” If I do set a Gradle Home location IDEA always uses it regardless of how the wrapper is configured. For example, if I have Gradle Home pointing to v1.3, but use v1.5 in my wrapper config, IDEA always uses v1.3.

    Since the setting for Gradle Home is grayed out when I choose “Use gradle wrapper” I assume I shouldn’t need to set it. Is there some trick I’m missing?

  14. Denis.Zhdanov says:

    Hi Ryan,

    It looks like your gradle wrapper is configured to use non-default location ( That’s why our gradle integration assumes that the project is wrapper-unaware and doesn’t offer that option (‘use gradle wrapper’ button is disabled)

  15. Denis says:

    Hi Denis.Zhdanov,

    Thank you for a great job. The updated Gradle integration looks awesome. But I still cannot wrap my head around the question: ‘How to enhance the generated xml files after project import?’

    As far as I understand this integration does not call the ‘idea’ task from the standard Gradle ‘idea’ plugin. Thus I cannot add some extra parameters to generated configuration (xml files). Could you please help me with that? Is there any way to catch an some sort of ‘event’ when project was imported and configuration files were created?


  16. Ryan says:

    Hey Denis,

    The only non-default setting I use is for a custom distributionUrl, but I have the same problem using the default wrapper config. I can select ‘Use gradle wrapper’, but whenever I try to run a task using JetGradle, I get the following message:

    This is what my config looks like:


  17. Denis.Zhdanov says:

    @Denis: what kind of project config modification would you like to perform? Are you asking on how to tweak IJ gradle integration programatically (via a plugin)?

    @Ryan: IJ gradle integration executes gradle tasks not via gradle api but from command line. That’s the problem’s reason. The whole integration is being redesigned now and the plugin will be available for manual update. Keep track of the news here –

  18. Denis says:

    Hi Denis.Zhdanov,

    Thank you for reply. Answer on your second question (if I have got it right) would be yes. That is exactly what I am trying to achieve. What I need:

    1) Tweak ‘Defaults’ in the configuration (to add -XstartOnFirstThread parameter for MacOS)

    2) Create RunConfigurations for our project when we import it to the IDEA.

    The second issue can be resolved by adding to the git repo .idea/runConfigurations folder but I don’t like this solution and would prefer to generate them automatically at the ‘import time’.

    Of course there is the ‘idea’ plugin provided by Gradle, but it is not so convenient to use it as JetGradle…

  19. Denis says:

    Hi Denis.Zhdanov,

    Could you please comment on this also: ? That discussion was in place 7 months ago, but it seems to me that JetGradle still does not support Scala well. Am I missing something here?


  20. Oleg says:

    Hi, have some questions:
    1. I tried to import gradle project into Idea. Stuck on “Gradle home” field – it claims “Gradle location is incorrect.” Tried almost anything. I’m using Linux Ubuntu, that’s why paths are something like “/usr/bin/gradle” or “/usr/bin”. I think, this is bug. Am I right?
    2. I want to migrate my Android project from Eclipse to Idea. Google guys do recommend to export the project into gradle then import it into Android Studio. Is Android supported by Idea’s gradle plugin too? (As I understand, both Android Studio and Idea should deliver equal functionality)

  21. Denis.Zhdanov says:

    @Denis: sorry for the long delay, just have seen your comment. So, it’s hard to customize the processing at 12.1.x. However, the whole integration has been re-written for v.13.x in order to generify external system support. Please have a look into, it has expressive documentation.
    Also we don’t have a special scala gradle support at the moment. Not sure with the ETA, sorry

    @Oleg: there might be a bug with symlinks processing. Please try to define a path without symlinks as a gradle home.
    Android-specific import is performed by android plugin. That code was introduced at the IJ 13.x branch, i.e. it’s not available at 12.1.x.

  22. Oleg says:

    @Denis.Zhdanov, you were right: that’s a bug with symlinks. I think, you need to file it to tracker as a feature to be implemented, because, it should automatically resolve such path problems (not only Gradle but everywhere in Idea).

    For those, who works under Linux, here’s the solution: imagine gradle has path “file /usr/bin/gradle”, e.g.

    file /usr/bin/gradle
    /usr/bin/gradle: symbolic link to `/etc/alternatives/gradle’
    file /etc/alternatives/gradle
    /etc/alternatives/gradle: symbolic link to `/usr/lib/gradle/default/bin/gradle’
    file /usr/lib/gradle/default/bin/gradle
    /usr/lib/gradle/default/bin/gradle: a /usr/bin/env bash script, ASCII text executable

    Next, point “/usr/lib/gradle/default” in “Gradle home” (without bin).

  23. Gus says:

    I’m having issue with this:

    task warAdmin(type: War, dependsOn: classes) {
    baseName = ‘admin’
    from ‘webapps/admin’

    The problem is intellij is incessantly asking me to import, but if I do that the build fails because war doesn’t implement task. How do I turn off this import feature, or otherwise convince intellij I want the war task from gradle?

  24. Denis says:

    Hi Denis.Zhdanov,

    Thank you for the answer. So, I guess there is no way but just wait to 13.x release. Looking forward for that!

  25. Denis.Zhdanov says:

    @Gus: we don’t provide any gradle-specific editing support at the moment. That will be addressed at the v.13 as well –

  26. Andrey says:


    As I understand, Gradle Tooling Api allows to redirect output.

    try {
    //obtain some information from the build
    BuildEnvironment environment = connection.model(BuildEnvironment.class)

    //run some tasks

    } finally {

    Automatic model refresh cycle:
    - Wait 5 seconds (configurable) after last edit
    - Save build.gradle file
    - Run build
    - Check for exceptions
    - Report to user if any
    - Update model if all looks good

    Something along those lines.

    Have a look at STS Gradle plugin, it works just fine, without verbose output, it runs on update, either when build.gradle is modified explicitly or with git pull/rebase.

  27. Denis.Zhdanov says:

    @Andrey: have you read the mentioned ticket I’ve created at gradle tracker ( It explicitly points that setting stdout/stderr via gradle api doesn’t suppress all problem output.

    The problem is not that we can’t automatically refresh project info on gradle script modification, the problem is that IJ logs would be full of garbage as gradle scipts have invalid state most of the time during editing.

    Nevertheless, we’re going to implement auto-refresh on gradle script editing by explicitly cutting all gradle output from that ‘not performed by end-user calls’

  28. Sandman says:

    Am I correct that IDEA isn’t properly handling the ‘buildscript’ section for dependencies? In my projects, if the dependencies are only on the buildscript (and not the project), Intellij doesn’t see them and assumes everything is an error.

  29. Denis.Zhdanov says:

    That is a gradle api drawback. Feel free to watch/vote up

  30. Peter Pilgrim says:

    The JetGradle / Gradle in IntelliJ is broken for my Java EE 7 book that uses multimodule.

    Given my book’s code structure:


    Whenever I open now a sub module say javaee7handbook/ch04/jpa-simple/build.gradle I find that IntelliJ replicates the whole structure inside the sub module!!!


    I need to disable Gradle support now. How do I so and just rely on the standard
    $ gradle idea

  31. Denis.Zhdanov says:

    Hi Peter,

    1. What do you mean by ‘open a sub module’? Do you perform ‘import from gradle’ for it?
    2. Could you try IJ 13.x EAP and check if the problem persists (


  32. Abhishek says:

    Hi there,
    We user IDEA 12.x Ultimate along with gradle. The Jet-Gradle plugin autumatically refreshes the project dependencies every time a project is opened. Is there a way this can be disabled so that refresh happens only when user needs ?

  33. TiGi says:


    I’m having issue when I click on the “Reload Gradle UI” button. I get this error :
    NoClassDefFoundError: Error during dispatching of java.awt.event.MouseEvent[MOUSE_RELEASED,(226,282),absolute(222,278),button=1,modifiers=Button1,clickCount=1] on frame0: org/jetbrains/plugins/gradle/util/GradleLibraryManager

    The gradle home path is correctly set in intellij settings.
    I found this post with the same error as me but still no positive response :

    Plus, I can’t choose the “Use gradle wrapper” option, I don’t know if there’s a link…
    Any idea?

    Anyway thanks!

  34. Jay Barr says:

    Can we expect Gradle support in WebStorm soon? Any word on timeline?

  35. skywalker says:

    Still cannot support “apply from” in build.gradle?

    such as:
    apply from: ‘gradle/dependencies.groovy’

    Project cannot sync dependencies from other scripts which included by ‘apply from’

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>