Categories
Ant Build Script Uncategorized

Execute Ant

It is xml based configuration file.

Following is HelloWorld configuration file “buildConfig.xml”. File can have any name. Open command prompt and copy file in current directory.

<?xml version="1.0"?>
   <project name="AntDemo" default="hello">
   <target name="hello">
      <echo>Hello World - Welcome to Apache Ant!</echo>
   </target>
</project>

Execute following Ant command

>ant -buildfile buildConfig.xml hello

As seen in command, we are invoking ant.bat having two command line parameters -buildFile and target to execute in the build file.

In the buildConfig.xml target “hello” is mentioned and invoked. Target “hello” consists of single in-built task echo to print the input message in config file.

It prints output on console by default. Each target is executed & printed on console. Here “hello:” target is executed & printed on console its output that is echo message. In the end it says “BUILD SUCCESSFUL” with return code 0.

Ant has several optional input parameters, that can be seen using following command

cmd>ant -help

Leave a comment

Design a site like this with WordPress.com
Get started