X

Geertjan's Blog

  • February 12, 2012

Gradle in NetBeans IDE 7.1

Geertjan Wielenga
Product Manager

I recently created a very simplistic Gradle plugin for NetBeans IDE 7.1:

http://plugins.netbeans.org/plugin/41776/gradle

This is how it works. Before getting started, make sure that you installation of NetBeans IDE supports Groovy.

Then, install the plugin, and you'll see this:

Then, after installing the plugin, before doing anything else, register your Gradle installation:

Next, go to the New File dialog and choose the "Gradle Desktop Build Script":

On the next page, make sure to name the script "build":

Click Finish in the dialog above and your new Gradle script will be created.

Switch to the Files window and you should now be able to expand the "build.gradle" file that you find there:

As you can see, you can right-click any of the Gradle tasks and run them. You can also double-click the file node to open the file in the Groovy editor:

The file above is exactly the content you'll get when choosing the "Gradle Desktop Build Script". When you make changes in the Gradle file, the node hierarchy will automatically be updated.

Make sure that you follow the steps above, in the order described above, before leaving comments about the plugin not working for you.

Join the discussion

Comments ( 8 )
  • guest Saturday, March 10, 2012

    Thanks a lot, Netbeans needs this to stay competitive. Though I wish this plugin was open source and not just you.


  • Geertjan Saturday, March 10, 2012

    It IS open source. Do you want to contribute?


  • Justin Ryan Monday, March 12, 2012

    Sorta. I'm typically a Netbeans users, but I've been having problems working with the Gradle codebase, so I switched to Intellij, which has better gradle support. I'd like to use Netbeans if possible and could spend a little time helping. First problem is having .gradle files being renamed to build.gradle. Is there a git/hg repo for this plugin? Is the CI for building/releasing the plugin?

    How far away is the plugin from supporting the blind importing of a build.gradle as a Project? Like how a maven project can be opened.


  • guest Friday, March 16, 2012

    NB 7.1 trying to expand build.gradle and IDE sits at Loading task...

    Starting Gradle daemon

    Starting daemon process: workingDir = C:\Documents and Settings\SGoldsmith\.gradle\daemon\1.0-milestone-9, daemonArgs: [C:\Program Files\Java\jdk1.6.0_31\bin\java.exe, -XX:MaxPermSize=256m, -XX:+HeapDumpOnOutOfMemoryError, -Xmx1024m, -Dfile.encoding=windows-1252, -cp, C:\projects\gradle-1.0-milestone-9\lib\gradle-launcher-1.0-milestone-9.jar, org.gradle.launcher.daemon.bootstrap.GradleDaemon, 1.0-milestone-9, C:\Documents and Settings\SGoldsmith\.gradle\daemon, 10800000, 7655365d-7928-45b1-bda1-8e6d4b945555, -XX:MaxPermSize=256m, -XX:+HeapDumpOnOutOfMemoryError, -Xmx1024m, -Dfile.encoding=windows-1252]

    SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor org.openide.nodes.AsynchChildren

    java.lang.NullPointerException

    at org.gradle.internal.nativeplatform.jna.WindowsProcessInitializer.makeUninheritable(WindowsProcessInitializer.java:54)

    at org.gradle.internal.nativeplatform.jna.WindowsProcessInitializer.initialize(WindowsProcessInitializer.java:41)

    Caused: org.gradle.internal.nativeplatform.jna.WindowsProcessInitializer$ProcessInitializationException: Failed to configure the standard stream handles to be 'uninheritable'.

    at org.gradle.internal.nativeplatform.jna.WindowsProcessInitializer.initialize(WindowsProcessInitializer.java:49)

    at org.gradle.launcher.daemon.client.DefaultDaemonStarter.startProcess(DefaultDaemonStarter.java:92)

    Caused: org.gradle.api.GradleException: Could not start Gradle daemon.

    at org.gradle.launcher.daemon.client.DefaultDaemonStarter.startProcess(DefaultDaemonStarter.java:103)

    at org.gradle.launcher.daemon.client.DefaultDaemonStarter.startDaemon(DefaultDaemonStarter.java:82)

    at org.gradle.launcher.daemon.client.DefaultDaemonConnector.createConnection(DefaultDaemonConnector.java:100)

    at org.gradle.launcher.daemon.client.DefaultDaemonConnector.connect(DefaultDaemonConnector.java:70)

    at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:104)

    at org.gradle.tooling.internal.provider.DaemonGradleLauncherActionExecuter.execute(DaemonGradleLauncherActionExecuter.java:44)

    at org.gradle.tooling.internal.provider.DaemonGradleLauncherActionExecuter.execute(DaemonGradleLauncherActionExecuter.java:31)

    at org.gradle.tooling.internal.provider.LoggingBridgingGradleLauncherActionExecuter.execute(LoggingBridgingGradleLauncherActionExecuter.java:53)

    at org.gradle.tooling.internal.provider.LoggingBridgingGradleLauncherActionExecuter.execute(LoggingBridgingGradleLauncherActionExecuter.java:30)

    at org.gradle.tooling.internal.provider.DefaultConnection.run(DefaultConnection.java:105)

    at org.gradle.tooling.internal.provider.DefaultConnection.getTheModel(DefaultConnection.java:98)

    at org.gradle.tooling.internal.provider.DefaultConnection.getModel(DefaultConnection.java:80)

    at org.gradle.tooling.internal.consumer.LazyConnection$3.run(LazyConnection.java:90)

    at org.gradle.tooling.internal.consumer.LazyConnection$3.run(LazyConnection.java:88)

    at org.gradle.tooling.internal.consumer.LazyConnection.withConnection(LazyConnection.java:98)

    at org.gradle.tooling.internal.consumer.LazyConnection.getModel(LazyConnection.java:88)

    at org.gradle.tooling.internal.consumer.ProgressLoggingConnection$2.run(ProgressLoggingConnection.java:61)

    at org.gradle.tooling.internal.consumer.ProgressLoggingConnection$2.run(ProgressLoggingConnection.java:59)

    at org.gradle.tooling.internal.consumer.ProgressLoggingConnection.run(ProgressLoggingConnection.java:74)

    at org.gradle.tooling.internal.consumer.ProgressLoggingConnection.getModel(ProgressLoggingConnection.java:59)

    at org.gradle.tooling.internal.consumer.DefaultAsyncConnection$2.run(DefaultAsyncConnection.java:53)

    at org.gradle.tooling.internal.consumer.DefaultAsyncConnection$2.run(DefaultAsyncConnection.java:51)

    at org.gradle.tooling.internal.consumer.DefaultAsyncConnection$3.run(DefaultAsyncConnection.java:71)

    Caused: org.gradle.tooling.GradleConnectionException: Could not fetch model of type 'BuildableProject' using Gradle installation 'C:\projects\gradle-1.0-milestone-9'.

    at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:46)

    at org.gradle.tooling.internal.consumer.DefaultAsyncConnection$3.run(DefaultAsyncConnection.java:73)

    at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:63)

    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

    [catch] at java.lang.Thread.run(Thread.java:662)


  • Geertjan Saturday, March 24, 2012
  • Roel Van der Paal Monday, April 9, 2012

    >IDE sits at Loading task...

    Same here.


  • guest Tuesday, October 2, 2012

    Do you think it would make sense to create a gradle project type for the netbeans platform . You could then provide templates for the creation of simple and multi project builds. Also I would like to override the error checking and code completion in the java editor to use the classpath provided by the gradle build file. Can you give me any pointers as to how that might be done and if it makes sense to do so?


  • Geertjan Tuesday, October 2, 2012
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.