JavaBeat
calling cards | international calling cards | phone card
Ant Home Articles Tutorials Java Interview Questions & FAQs Java QnA Code Junction

1. Introduction

2. Ant Defined

3. Java Application with Ant

4. Sample build script

5. Common ant tasks

6. Summary

Common Ant Tasks

Task

Description

Javac

Compiles a Java source tree; intelligently scans through a source tree looking to compile Java files that have no corresponding .class file or where the class file is older than the .java file. A javac node is a fileset node that can specify a set include and exclude patterns to customize the file list to be compiled (more on this below).

Jar

Creates a Java Archive (JAR) containing a set of files. This node too is a fileset so that you have more fine-grained control over the files to be included in the JAR

War

This is an extension of the Jar task with specific knowledge of the Web Archive directory structure. Specifically it defines an attribute named "webxml" that specifies the web.xml file for the archive, a "lib" nested element that specifies all files that should be stored in the WEB-INF/lib folder, a "classes" nested element that specifies all files that should be stored in the WEB-INF/classes folder, a "webinf" nested element that specifies all files that should be stored in the WEB-INF folder, and finally a "metainf" nested element that specifies all files that should be stored in the META-INF folder.

Ear

This is an extension of the Jar task with specific knowledge of the Enterprise Archive directory structure. Specifically it defines an "appxml" attribute that references the enterprise application's application.xml file and a "metainf" nested element that specifies all files that should be stored in the META-INF folder.

Javadoc

This task is used to generate code documentation with the javadoc tool. Your code should have specific Javadoc comments defined in it to expose the purpose of classes, methods, and public attributes. This task provides fine-grained control over the behavior of the javadoc tool, so I encourage you to read more in the Ant manual.

Java

This task is used to execute a Java class within the Ant JVM or fork a new JVM if specified. Thus through this task you can execute any Java application and you can send it input, such as the location of build directories and so forth.

Ant

This task is used to execute Ant on a specified build file. Most commonly this task is used to build subprojects.

Mail

This task is used to send SMTP emails. Most commonly this is used to notify team members when a build completes, but it can also be used to distribute files because it can send attachments such as build log files and the final distributable files.

Get

Gets a file from a URL, including support for the following URL schemas: http, ftp, and jar. This is useful if you need to obtain certain files maintained on a server somewhere. For example, at my company we have certain native components that require that Microsoft Visual Studio be installed to build. Rather than require all developers to install Visual Studio, the compiled files are built on the server and retrieved by Ant during the build.

Additionally there are a set of helper tasks that perform common operations that you will need, these include: Copy, Delete, Mkdir, Move, Unjar, Tar, Untar, Unwar, Zip, Unzip, GZip, and GUnzip. Again, refer to the Ant manual for more details on each of these tasks. And for those of you using CVS, there are a set of CVS tasks built into Ant's core: Cvs, CvsChangeLog, CvsVersion, CVSPass, and CvsTagDiff.


Favorites
AffiliatedAds.com
Buy movies
Access Control
Busby seo challenge contest
Sohbet
Chat
Webmaster Hosting Forum
Java Jobs
MyVideoLib
India News
Internet Advances
Sohbet
chat
Latest QnA
SCJD Tips
When we start a thread by applying start() method on it ,how does it knows that to execute run()method?
About Wrapper class in Java
How to configure weblogic 7.0 in MyEclipse?
Static Block and Static Initializer in Java

JavaBeat Website (2004-2008), India
javabeat | about us | planetoss
Copyright (2004 - 2008), JavaBeat