How can I get a list of build targets in Ant?
To get all the targets in the build file
ant -p -verbose
The -p
or -projecthelp
option does exactly this, so you can do:
ant -p build.xml
You can make a target to invoke this like:
<target name="help">
<java classname="org.apache.tools.ant.Main">
<arg value="-projecthelp" />
<arg value="-buildfile" />
<arg value="${ant.file}" />
</java>
</target>
which you can then set as the default, so just typing ant will list the available targets.
(Combining @Grodriguez' answer and @sschuberth's comment - I thought it was worth an answer by itself)
The -p
or -projecthelp
option does exactly this, so you can just try:
ant -p build.xml
From ant's command line documentation:
The
-projecthelp
option prints out a list of the build file's targets. Targets that include adescription
attribute are listed as "Main targets", those without adescription
are listed as "Other targets", then the "Default" target is listed ("Other targets" are only displayed if there are no main targets, or if Ant is invoked in-verbose
or-debug
mode).