After having read the book Beginning Groovy and Grails: From Novice to Professional, I was wondering if it was ever going to be as simple as a few clicks in any IDE for Grails development. Just yesterday, I read an article by Geertjan Wielenga(who is also my colleague at Javalobby/DZone) about how to get started with Grails in NetBeans IDE 6.5 in 5 simple steps. I had worked with NetBeans quite a lot for EJB3 development but I had never used it for either Groovy or Grails; the choice earlier was always Eclipse IDE.

I first followed the Book Demo and later moved to a more real life example. This was a litmus test which I thought NetBeans had to pass for developers to continue using the same for Groovy/Grails development. The example in the book has a few relationships; which is what we would generally have in any enterprise application.
domain-classes
I was able to create all the domain classes, controllers, manage relationships without ever leaving the IDE. Creating a Domain class or even a Controller, is as simple as right clicking on the appropriate nodes and providing meaningful names. The IDE creates the skeleton classes; we need to provide the meat within and here is what the Todo Domain class looks like:

class Todo {
    String name
    String note
    Date createdDate
    Date dueDate
    Date completedDate
    String priority
    String status

    User owner
    Category category

    static belongsTo = [User, Category]

    static constraints = {

        name(blank:false)
        createdDate()
        priority()
        status()
        note(maxSize:1000, nullable:true)
        completedDate(nullable:true)
        dueDate(nullable:true)

    }

    String toString() {
        name
    }

}

Right-click the application in the IDE and choose “Run”. The application is deployed to Jetty, and then you’ll see your application as shown below:

book-example

If you are a Groovy or a Grails fan, download the latest version of NetBeans and give it a try. You can develop, test and run your Grails application without ever opening a command window. The Groovy editor has basic coloring, formatting and bracket completion. The GSP editor has coloring, highlighting of GSP tags, expressions and scriptlets. You can mix and match Java and Groovy as well.

P.S: Groovy and Grails home needs to be set from within the IDE NetBeans/Preferences as shown below:
grails-home

Resources: