The simplest and best way to invoke ant from within an ant build script is to use the core ant task provided for that purpose.
Typical examples of usage:
<ant antfile="subproject/subbuild.xml" target="compile"/> <ant dir="subproject"/>However, if you want to run ant in a way not supported by the core ant task, such as to pass non-standard command line parameters, one can use the core java task instead:
<java classname="org.apache.tools.ant.launch.Launcher"> <classpath path="${java.class.path}"/> <arg value="-projecthelp"/> </java>or
<java dir=".." classname="org.apache.tools.ant.launch.Launcher" fork="true" failonerror="true"> <classpath path="${java.class.path}"/> <arg value="-projecthelp"/> </java>
I found this useful for doing TestDrivenDevelopmentInAnt? -- writing ant scripts that test other ant scripts.