Attila has posted 2 posts at DZone. View Full User Profile

Gradle Plugin for NetBeans IDE 7.2

  • submit to reddit
I ( have been (and I still do) use Maven for development of Java code. My main reason for using Maven for development is its great NetBeans IDE support, so that I don't need to maintain IDE project files separately.
As much as I like this support in the Maven world, I feel the limits of Maven every day I use it.

Since I first saw the Gradle project, I knew that this is the least that I've always wanted from a build tool. So I started to look for NetBeans IDE support for Gradle. To my sadness there is only support for Eclipse and Idea. Aside from the fact that I prefer to use NetBeans IDE, I felt the IDE support to be limited for Gradle, (although the last time I read about Gradle support in IDEA, it seemed promising). 

Not long ago, I came across Geertjan's plugin and I felt that that writing such plugin is possible without enormous effort. So I downloaded his sources and started to analyze them and rewrite the plugin, so that it works with most Gradle scripts. There are many new features available in my version, such as these:
  • slow tasks are done in a background thread
  • source paths are retrieved from the model
  • "test single" 
  •  Project menus:
  •  Project dependencies:
  •  Project debug test:

However, I removed subprojects and now each project needs to be opened manually, it is more efficient if you don't plan to edit all the subprojects; the drawback is that you cannot open projects without a build.gradle. 

The main problem with Gradle daemon performance is that on the first project load, Gradle downloads every single dependency. After that, I found the performance acceptable (especially after I implemented caching of already loaded projects). I have tested it with a relatively large project (>60 subprojects, lots of Java code): It took me about 2 minutes to load the project which seems ok to me for such an enormous project. Other than the project loading, the performance depends on NetBeans which is good.

How to try it

There is currently no compiled version of the plugin, so you have to compile it for yourself, if you want to try it.

You can clone/download the sources from here:
After downloading the sources, open the project in NetBeans IDE.
There generally two approaches you could consider:
  • Generate the .nbm file (by choosing "Create NBM" in the project's popup) and install the plugin as you would do with any other third-party plugin.
  • "Run" the project. This is the safest thing to do because this will start a new NetBeans instance with a brand new user directory (in the build folder). This way your own NetBeans installation will be unaffected.

Help I would appreciate

I'm pretty new to the NetBeans APIs (i.e., this is my first time using them), so someone might help me with the project dependencies (possibly Mavenize the plugin). And if it is possible, allow for the plugin to rely on a user specified installation of Gradle (there is some risk in it because Gradle does not seem to be very backward compatible).

If you happen to know the Project API in NetBeans well, that could prove really helpful, so that I don't need to spend days figuring out, how things need to be done in the API.

How to contact me

You can contact me through my GitHub account:
Published at DZone with permission of its author, Attila Kelemen.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Javier Ortiz replied on Mon, 2012/08/13 - 8:59am

Great work! I'm currently moving to Maven but Gradle seems more appealing each day...

Alex Kotchnev replied on Mon, 2012/08/13 - 9:27am

Atitila - very cool, checking out project sources as we speak! My Tapestry5 based project currently uses Maven, and so far the usage is pretty basic. I've toyed w/ the idea of switching it over to Gradle (which should work w/ minor tweaking); however, the biggest hurdle is the sparse IDE support, which I hope a plugin like yours might be able to address. 

Milos Kleint replied on Fri, 2012/08/17 - 7:52am

It takes some time before you can actually start edit the code because the Gradle Tooling API will do everything before actually returning models to work on. This is especially painful on the first project open because it will actually download every single dependency before returning (even test dependencies).

I came across this paragraph  in the source code's readme. what exactly is the definition of "will do everything"? does it include building the project? executing the build script only?

Attila Kelemen replied on Sat, 2012/08/18 - 5:52am in response to: Milos Kleint

It means, that when the project is opened, the tooling api of Gradle will make sure, that every dependency is available locally (sources, test dependencies, etc.) and will also load every project which is part of the multi project build even if it is not a dependency of the project (this is necessary for Gradle, since any project may modify any project in a multi project build). That is, when I request Gradle to parse the project it returns everything to me in one step. It will not execute any tasks when opening the project, it is just slow compared to opening a Maven project. However I implemented a simple optimization: since Gradle loads every project of a multi project build, I will cache the parsed project, so opening other project of that particualry multi project build will be an instant. Also, reloading a project, automatically reloads every project of the multi project build.

Building, executing tasks, etc. takes exactly as much time as if you were executing it manually (with the Gradle daemon).

You may try it and see for yourself if the performance is adequate. For convenience, I have shared the compiled NetBeans module as well:

Attila Kelemen replied on Sun, 2012/08/19 - 7:48pm

If you have checked the plugin, you are encouraged to dowload it again from

It is now possible to set the installation directory of Gradle and setting it greatly increases performance. You can set it on the Tools/Options/Miscellaneous/Gradle panel. Also it is now possible to open projects not having a "build.gradle" (by opening their parent and opening them from there).

Martin Janíček replied on Mon, 2012/08/20 - 8:42am

Hi Attila, I'm actively working on the Groovy & Grails support in NetBeans and I would really like to help you with the Gradle plugin development. Although I will not have enough of time for the active development in the next few months. But if the only thing you need is to answer to a specific NetBeans API question from time to time, don't hesitate to contact me and I'll definitely try to help!

Matt Coleman replied on Fri, 2012/11/16 - 12:47am

Attila, again another one of such an awesome idea..again i cannot stress how sell sheet designer  appreciates it 

Johan Botha replied on Sat, 2013/02/09 - 5:34am

Pacoima Garage Door Repair  I am really impressed by this excellent stuff. I always prefer to read the quality content and this thing I found in you post. Thanks for sharing.

Johan Botha replied on Fri, 2013/02/15 - 5:17am

diecasinospiele die beliebtesten online spiele     I have to say that the news here was the most complete that I found anywhere. I am definitely bookmarking this to come back and read later.

Cata Nic replied on Tue, 2013/09/03 - 2:36am

 Is this method available for the 7.3 version too? I want to use it for my clients solutions, too.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.