ant Hello World


Example

Add the following to a file named build.xml in your project directory:

<?xml version="1.0" encoding="UTF-8"?>
<project name="HelloWorld" default="main">
    <target name="main" description="this is target main">
        <echo message="Hello World" />
    </target>
</project>

From a command prompt on a computer running Windows, executing ant main will display similar to the following:

$ ant main
Buildfile: C:\Users\<me>\Projects\HelloWorld\build.xml

main:
     [echo] Hello World

BUILD SUCCESSFUL

Also, user can now run the command ant as default target name added to the project. When ant command is run, it looks for project's default target and execute it.

$ ant 
Buildfile: C:\Users\<me>\Projects\HelloWorld\build.xml

main:
     [echo] Hello World

BUILD SUCCESSFUL

If the build script is written by some one else and the end user like to see what target he can run, run the command which will show all the targets which has descriptions.

$ ant -p