Friday, July 23, 2010

Watch Directory For Changes in Groovy

One must-have feature in any modern web stack is the ability to automatically restart/refresh the development server when you edit the source code. It is critical for developer workflow that the feedback loop be as tight as possible. Here source code refers to actual class definitions, templates (JSPs, GSPs, haml files, etc...), static content (javascript, css, images), AND configuration (I'm looking at you, struts.xml).

All web frameworks which do not support automatic updating of all content during development shall hereafter be referred to as "Legacy Web Frameworks". Is your shop using them?

Justin Voss and I have been hard at work on a web micro-framework called Ratpack (inspired by Ruby's Sinatra). Lest it become a Legacy Web Framework right out of the gate, we've implemented basic auto-reloading right away. Feel free to grab this for other uses, as it works independently.

groovy runapp.groovy app/myapp.groovy app

The script app/myapp.groovy will be killed and re-run when any content in the app directory changes.

Since Ratpack uses Jetty, there are probably better solutions. Feedback is welcome.

The NIO.2 Filesystem in JDK7 will make this sort of thing much easier.

1 comment:

Michael Finney said...

That is so awesome. Fast feedback like that lets the mind flow freely and the great web solutions just keep on coming!