grailsgroovygant

How to run Gant targets from within a Grails controller?


Suppose I have a block of Gant code:

 target(echo:"test"){
    ant.echo(message:"hi")
 }
 setDefaultTarget("echo")

This is usually run from a command line.

How could I place the block in a Grails controller and run it from there?


Solution

  • You can use AntBuilder for this:

    class FooController {
    
       def index = {
          def ant = new AntBuilder()
          ant.echo(message:"hi")
       }
    }