Over a million developers have joined DZone.
Platinum Partner

Why I Like Using Gradle in NetBeans IDE (Part 2)

· Java Zone

The Java Zone is brought to you in partnership with ZeroTurnaround. Discover how you can skip the build and redeploy process by using JRebel by ZeroTurnaround.

Part 1 of the NetBeans/Gradle series came from Martin Steffen in Uruguay. Below, in part 2, we travel to Scotland!


My name is Douglas Maxwell. I’m Scottish and  a Java software consultant specializing in financial apps. 

I’ve been using Groovy for over a year now and that is what led me to start experimenting with Gradle. I enjoy the terseness and expressiveness of the Groovy language, which I am able to exploit for build management with Gradle, no more XML verbosity and the ability to exploit Ivy’s excellent dependency management.

I manage my own software codebase in Subversion. I develop using agile methods which means lots of unit and integration tests. The codebase is managed with Gradle and the CI jobs are executed on a Jenkins server. I prefer to develop in NetBeans IDE using Gradle to manage my projects primarily because of the excellent support for dependency management and the ease of use when configuring multi-project builds.

What follows is a short description of a basic server side module for trade capture and my typical development workflow:

  1. Go to Tools | Plugins in NetBeans IDE 7.2 and install the Gradle plugin. Then open or create a Gradle Java project in NetBeans IDE, using the Open Project dialog or New Project dialog to do so.
  2. Write code and configure dependencies in the Gradle "build" file:

    This project consists of some service and DAO classes.  It uses Spring JavaConfig and JPA to manage persistence. The database is sql server 2012 in spite of the fact that I am a big fan of Oracle 11g. There is a single integration test which runs a Groovy script to set up the database schema and inject the initial test data. Here is the build file.

    As you can see it uses artifacts from a local Ivy repository. The output from the build is deployed to the same repository.
  3. I run all the test locally:

  4. The changes are then committed to the Subversion repository. Currently I do this external to NetBeans IDE, though I think this can be done from the IDE with the latest version of the plugin.

  5. As this project is not part of my main build, I have setup a separate gradle job in Jenkins,  which runs when changes are detected in the Subversion repository.


I am very impressed with the NetBeans plugin for Gradle so far. Rarely do I have to step out of NetBeans IDE and run a part of the build from the Gradle command line. I would, however, like to see some of these features added:
  1. the ability to add command line switches when a task is executed
  2. the ability to navigate test results in the Projects window
  3. the ability to add Groovy sources
  4. the ability to create different types of Gradle projects with the appropriate plugins and dependencies added automatically
  5. the ability to have a project update automatically when changes are applied to the build file.

The last feature might be implemented but it just doesn’t seem to work for me!

The Java Zone is brought to you in partnership with ZeroTurnaround. Discover how you can skip the build and redeploy process by using JRebel by ZeroTurnaround.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}