Q:

Move a ant dir project after the ant or subant task completes

Currently i'm using a shell script to do the following:
cd myproject1/
ant
cd ..
if grep 'sucessful' myproject/buil.log then move myproject ../backup/today/

And so on for myproject2, myproject3.
If some error happens, the project stay in the current dir to be reprocessed but the whole process continues.
I want to migrate this process to an ant build script but i have no clue on how to do this.
I have looked at ant and subant tasks. Ant looks more suitable to the job but i can't find a way to loop through a directory list using ant and move task togheter, checking if the ant task completes or not.
Thank you.

A:

Checkout this answer:
running specific target in different ant scripts in different directories
I recommend that your submodule builds should throw an error rather than try and duplicate the log parsing logic.
Update
If this is designed to support deployment, perhaps you should consider a groovy script?
Would better support exception conditions:
def ant = new AntBuilder()

scanner = ant.fileScanner {
    fileset(dir:".", includes:"test*/build.xml")
}

scanner.each { f ->
    try {
        ant.ant(antfile:f)
    }
    catch (e) {
        ant.mkdir(dir:"backup")
        ant.move(todir:"backup", file:f.parent) 
    }
}

Groovy has excellent ANT integration and can also be embedded within your ANT build:
<target name="run">
    <taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/>

    <fileset id="buildFiles" dir="." includes="test*/build.xml"/>

    <groovy>
        project.references.buildFiles.each { 
            def f = new File(it.toString())
            try {
                ant.ant(antfile:f)
            }
            catch(e) {
                ant.mkdir(dir:"backup")
                ant.move(todir:"backup", file:f.parent) 
            }
        }
    </groovy>
</target>

