ant Getting started with ant Hello World

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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


Got any ant Question?