When you invoke ANT from the command line, you can specify -projecthelp or -p as part of your ANT call. By adding one of these options to the command line, you will receive a list of all targets that have a description attribute defined. Often, these types of targets are referred to as top level targets. These are targets that have all of their dependencies defined and can typically be run without any issues.
Top level targets can depend upon other top level targets, but typically they will depend upon lower level targets that do not have a description or their dependencies properly defined. These low level targets do not normally define their dependencies as this creates to much of a burden on the author of the build script when adding and removing new/old targets.
When creating a new build script, I find it beneficial to define all top level targets in the same section of the file. To increase readability of the build script and to keep the intention of the build clearly defined, all top level targets should have no nested tasks within their body instead relying on the element’s depends attribute to define the implementation for each target. For example:
<target name="build" depends="init-build, build-compile" description="Target to compiles all production source."/>
By following this strategy consistently it is possible to change the way a build works quickly and easily without getting bogged down in implementation details.
A common exception to this strategy is the implementation of a clean top level target. As the clean target usually has a simple implementation, I will often define a clean target at the end of my top level targets like the one below:
<target name="clean" description="removes the build and dist temporary directories and any files found within."> <delete dir="${build.dir}"/> <delete dir="${dist.dir}"/> </target>