I am trying to automate a build process that involves looping over a few directories and running "ant all" on all of them. All of them have aa simple build.xml.
I can do this via a shell script but I am using other stuff from within Groovy, for example, using the UI Performance Grails Plugin, so would like to stick to Groovy.
All documentation/forums on the web/other questions on SO, talk about running ant.exec and other AntBuilder methods but I didn't get to run a simple ant all.
Try the following example.
def ant = new AntBuilder()
ant.fileset(id:"builds", dir:".", includes:"**/build.xml")
ant.project.references.builds.each {
ant.project.log "Building ${it}"
ant.ant(antfile:it, target:"all")
}
Works for me as a standalone groovy script (I haven't tried calling it from grails)
I found a simpler way, using a subant task. Something like this:
ant.subant(target:"all") {
fileset(dir:"${pathToBuildDir}" includes:"build.xml")
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.