Ant – Build Process Automation

by seetaram on June 30, 2011

Software build is the process of creating and packaging binaries for the software release.  To make the build process completely consistent and repeatable, the process should be automated.  There are various tools available for the build process automation.

Build tools are used for the process of automating mundane activities such as:

  • Compiling source code
  • Packaging the binary files (i.e.  JAR / WAR /EAR files)
  • Running tests (Executing unit tests / UI tests)
  • Deployment of the application to containers such as JBoss, WebLogic, WebSphere, Tomcat, etc
  • Creating documents

Below are some of the tools available for build process automation:

  • Apache Ant
  • Apache Buildr
  • Apache Maven

Apache Ant is an open source build tool used for automating build process by Java development teams.  This uses XML for the build process.  Ant script that is used for build process is named as “build.xml”

Following is an example of “build.xml”:

<project name=”LearnANT” default=”display” basedir=”.”>

<target name=”display” >

<echo message=” Base Directory = ${basedir}”/>

<echo message=” Author: = Seetaram Hegde”/>

<echo message=” Source: = www.selftechy.com”/>

</target>

</project>

In the above example, target tag is something which needs to be parameterized while executing the ANT command.  For example, if the build.xml is located in C:\ then go to respective directory and then execute Ant {target} and press enter that executes the build.xml with the target specified after the Ant command

Execute this simple build.xml file with ANT and I think this will be the first step in learning Ant

{ 3 comments… read them below or add one }

Susmitha November 29, 2011 at 12:53 pm

Hi,

How to create ant build.xml in Eclipse ide?

Reply

seetaram November 29, 2011 at 6:05 pm

Use Export –> ant build file

Reply

Mohammed Ali November 10, 2012 at 4:53 pm

Hi,

I am having the below error while running the Ant from eclipse.

[junitreport] : Error! The first argument to the non-static Java function ‘replace’ is not a valid object reference.
[junitreport] : Error! Cannot convert data-type ‘void’ to ‘reference’.
[junitreport] : Fatal Error! Could not compile stylesheet
[junitreport] Failed to process F:\workspace\JUnit_ANT_Project\junit\TESTS-TestSuites.xml

BUILD FAILED
F:\workspace\JUnit_ANT_Project\build.xml:110: Errors while applying transformations: Fatal error during transformation

Total time: 46 seconds

Please provide me your suggestions to solve this error.

Thanks,
Ali

Reply

Leave a Comment

Previous post:

Next post:

Do you want to get updates on the recent articles written? Please subscribe to RSS feed or Email