Grails and Groovy Eclipse plugin

Versions : Grails 1.1-RC1, Maven 2.0.10, Eclipse 3.4.1, Groovy Eclipse plugin 1.6.0.200902111305.

1. Install and Configure Groovy Plugin

The Groovy Plugin is “work in progress”, as codehaus says. (http://groovy.codehaus.org/Eclipse+Plugin).

  • Choose the Groovy 1.6 version

For the upcoming version of Groovy 1.6 a first version of updated plug-in (Groovy version 1.6-RC3) is available here :

http://dist.groovy.codehaus.org/distributions/updateDev_1.6/

(Since Grails 1.1-RC1 embeds Groovy 1.6.0…let’s use it.)

 

  • Install the Groovy Eclipse plugin

Go to “Help / Software Updates / Available Software”. Click “Add Site” : http://dist.groovy.codehaus.org/distributions/updateDev_1.6/

image

Check “GroovyFeature”, and hit Install… And accept to restart Eclipse when asked.

  • Associate groovy files to the Groovy Editor by default

“Window / Preferences …” :

image

 

2. Verify that the Groovy plugin is working

  • Configuration

In the project’s properties, a Groovy Builder was added, and a “Groovy Project Properties” item appears.

image  image

No change needs to be made for the moment.

 

  • Auto completion

Create a Controller in demo/grails-app/controllers, named “TestController.groovy”. Open with Groovy Editor.

TestController.groovy :

class TestController { 
  def index = {
     return "foo" + "bar"
  }
}

Try Auto completion : for example when starting to type “new Big” and hitting Ctrl+Space, the following completion box appears :

image

  • Step by Step debugging

Add a breakpoint on the line “return ..”. (Double click in the left gutter).

image

Start “demo-mvn-grails-run-app” (this configuration was created previously)

Browse to “http://localhost:8080/demo/test/index”… And the breakpoint will activate.

image

Step-by-step debugging (F6) is working.

Note : Since the “index.gsp” file corresponding to the TestController was not created, an “HTTP 404 – Not Found” page will show up.

0 comments:

Post a Comment