Printing output in Grails 2.0 ant scripts

When developing plugins, in my case the Grails Fitnesse plugin, it’s sometimes handy to produce output to the user. In my case, I had a use case to give the user some information that Fitnesse had started up succesfully, and wanted to indicate the location Fitnesse was running on.

In previous versions of Grails (1.3.x), you could do ant ant.echo. However, as described in the Grails 2.0 release notes, the ant.echo doesn’t work anymore, and you’ll have to use ‘alternative mechanisms for output’.

Well, Spring Security Core had this already figured out. Just send a StatusUpdate event, which will be printed to the console automatically.

This be handy in the future for other plugin developers.

3 replies
  1. Matt Follett
    Matt Follett says:

    I didn’t know that you could do it like that. I have been using a different approach which is to use the methods provided by grailsConsole, e.g.:
    grailsConsole.addStatus "message"
    or
    grailsConsole.updateState "message"

    • Erik Pragt
      Erik Pragt says:

      Hi Matt,
      Thanks for the reply. You are right, I actually only discovered that today while checking out _GrailsTest.groovy. I’ll update the code!
      Thanks, Erik

Comments are closed.