mavengroovyantbuilder

Specify Groovy AntBuilder execution directory


I can execute a pom.xml with goals using AntBuilder like so.

def ant = new AntBuilder()
ant.sequential {
    exec(executable:'mvn') {
        arg(value:'clean')
        arg(value:'install')
    }
}

But how do I specify the execution directory to the AntBuilder? I'd like to just pass an absolute path.

For the record I've tried.

ant.project.setProperty('basedir', "${serviceRootDir}/")

and

ant.sequential {
    mkdir(dir:"${serviceRootDir}/")...

You'd think this would be clear in the doc.


Solution

  • This works for me:

    ant.exec(executable:"ls", dir:"/your/desired/directory")
    

    It executes ls in the given directory, so mvn should work.