I like what I’ve seen of Groovy and the Grails framework seems excellent, however it is massive. Sometimes you don’t want a huge framework if you’re just setting up a simple web app. Micro frameworks like Sinatra in Ruby and Express in Javascript for Node.js have popped up recently to address that need and have a pretty loyal following.

Looking around there are a couple written in Groovy that look interesting so I attempt to get out the obligatory ‘Hello World’ in one called ‘Graffiti’. Running into a couple of early problems with Maven and Ivy I thought I’d write up my experiences.

This was done on a Mac running OS X 10.6.6 with the standard Maven 2.2.1 install; Git was installed via MacPorts.

git clone https://github.com/webdevwilson/graffiti graffiti
cd graffiti
mvn resources:resources groovy:compile install

That should pull in all the required resources to the local Maven repository and then compile and install the Graffiti jar to the same place.

This is a very simple ‘Hello World’ which will output the expected text:

import graffiti.*

@Grab('com.goodercode:graffiti:1.0-SNAPSHOT')
@Get('/')
def hello() {
    'Hello World!'
}

Before the simple example above can be run the local Maven repository needs to be added to the Grapes config file for the Grab annotation.

Add this into ~/.groovy/grapeConfig.xml along with the other ‘ibiblio’ elements. For more information see the Grape documentation on the codehaus site: http://groovy.codehaus.org/Grape

<ibiblio name="local" root="file:${user.home}/.m2/repository/" m2compatible="true"/>