Apache Ant

Lemon Kazi
Oceanize Lab Geeks
Published in
3 min readApr 29, 2019

What is Ant?

“Apache Ant is a Java-based build tool. In theory, it is kind of like Make, but without Make’s wrinkles” -Apache Ant Website

Why Ant then?

Ant is different

· Ant has Java Class like extensions

· Use of XML instead of Shell Scripts

· Each task is taken care by creating its object

· Standardized

· Platform Independent

Where to get it?

You can get Ant from the following links:

●Apache Ant Homepage:

http://ant.apache.org

(Download > Current Release of Ant > apache-ant-bin.zip 11MB Approx)

● IDE: Ant comes in as bundled 3rd party tool/modules with IDEs like Eclipse, Netbeans, IDEA

build.xml

● Similar to make file but an XML file

● Its the default file where ant will look for what to build, how to build

● Has projects, targets, tasks

<Project>

Three attributes of <Project>

1) name: [Optional] Name of the project

2) basedir: [Optional] The base directory for path calculation. If not set then directory of the build file will be taken as the basedir

default: [Required] The default target to be called when no target is specified in command line.

A <Project> may have one or more <target>

● A <target> defines set of

● A < target > may depend on other

● A < target > gets executed only once

● A < target > has properties which determines how it will be executed

● A < target > can be specified when executing ant from command line

<task>

Independent code which can be executed

● Can have multiple attributes

● Ant has some built-in ready to be used tasks

Hello World with Ant:

Lets compile , pack and run a simple Hello World program in Java.

Step 1: Write your Java source code

Step 2: Write a build.xml file

Step 3: Run Ant with the build.xml

Lets write the build.xml First of all ,:

lets examine what you want to do:

●You’d like to Compile

●You’d like to package it into a Jar file.

●You’d also like to clean up the mess.

●Finally you’d like to run your application

●Lets create the root tags ..

Run the Ant:

Place your files in the class path and execute:

Ant Resources:

Homepage: http://ant.apache.org User Manual: http://jakarta.apache.org/ant/manual/index.html

Wiki: http://wiki.apache.org/ant/FrontPage

FAQ: http://ant.apache.org/faq.html

Books: http://sourceforge.net/projects/antbook

Contribution: http://www.apache.org/foundation/contributing.html

--

--