Ant

  • Apache Ant is a Java library and command-line tool that help building software.
  • Ant is open source
  • ANT: Another Neat Tool
  • http://ant.apache.org

Ant Tasks

Ant version

1
2
c:\antDemo>ant -version
Apache Ant(TM) version 1.10.1 compiled on February 2 2017

Structure of build file:

  • build.xml is the default ant script file.
  • Project is the root tag.
  • Project consist of many targets.
  • Targets have ant tasks.

Running ant build:

  • If you just run ant command, by default ant will look for a file name build.xml in current directory.

    1
    c:\antDemo>ant
  • Explicitly provide a build file using flag:-buildfile

    1
    c:\antDemo>ant -buildfile build2.xml

Project tag and default attribute:

1
2
3
4
5
6
<?xml version="1.0" ?>
<project name="FirstTest" default="hello">
<target name="hello">
<echo message="hello world" />
</target>
</project>

depends attribute for target chaining:

1
2
3
4
5
6
7
8
9
<?xml version="1.0" ?>
<project name="FirstTest" default="world">
<target name="hello">
<echo message="hello" />
</target>
<target name="world" depends="hello">
<echo message="world" />
</target>
</project>