An Ant target is a sequence of tasks to be executed to perform a part (or whole) of the build process. Ant targets are defined by the user of Ant. Thus, what tasks an Ant target contains depends on what the user of Ant is trying to do in the build script.
To run the ant build file, open up command prompt and navigate to the folder, where the build. xml resides, and then type ant info. You could also type ant instead. Both will work,because info is the default target in the build file.
Create Ant build file In the Project tool window, select the directory, where the build file should be created. Right-click the directory and from the context menu, select New | File ( Alt+Insert ). In the New File dialog, specify the name of the new file with the xml extension, for example, build. xml.
The -p or -projecthelp option does exactly this, so you can just try:
ant -p build.xml
From ant's command line documentation:
The
-projecthelpoption prints out a list of the build file's targets. Targets that include adescriptionattribute are listed as "Main targets", those without adescriptionare 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-verboseor-debugmode).
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)
You can check the list of target and default target in build.xml by the following command
ant -p built.xml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With