| Table of Contents |
Ant tasks are commands to perform various functions, such as compiling the source code, packaging classes, attaining file versions from Concurrent Versions System (CVS), copying files and directories, compressing files, and changing file permissions.
This chapter describes the built-in, optional, and user-defined tasks of Ant. It also explains how to write tasks, set up the build environment, use the tasks, and test the tasks.
Ant tasks consist of various attributes that specify their functions, such as a unique ID for the task, a task name, and comments. The syntax for an Ant task is:
<taskname atbtype="value1" atbtype="value2"..........>
This syntax consists of the name of the atbtype task, which specifies the attribute type and the corresponding value of the attribute. The value specifies the function of the Ant task. For example, the following command copies the abc.log file to the dir directory:
<copy file = "abc.log" toDir="dir"/>
The features of Ant tasks are:
Ant tasks are Java classes that you can customize according to your requirements. For example, you can customize the tasks to allow you to work with the C# language or third-party tools, such as Bureau of Economic Analysis (BEA's) WebLogic.
Ant tasks are cross-platform, which allows you to execute them on all platforms.
Ant tasks use XML tags for scripting.
The three types of Ant tasks are:
Built-in tasks: Are available with the core distribution of Ant. These tasks are linked to the core Java Development Kit (JDK) and the build process. For example, the <javac> task helps compile Java source files and the <jar> task helps package and unpackage the Java Archive (JAR) file. This file includes the compiled form of Java source files.
Optional tasks: Require additional JAR files for execution. For example, the <telnet> task helps interact with remote Telnet servers.
User-defined tasks: Are developed by end users who extend the core Ant task classes. You can use user-defined tasks to extend the functioning of Ant by writing a new Java task class.
Each Ant task contains a set of unique attributes to specify its functioning. A specific set of attributes, such as Id, taskname, and description are common to all Ant tasks. The common attributes of Ant tasks are:
Id: Specifies a unique ID for the task instance. This helps reference a specific task from other tasks.
Taskname: Specifies an alternative name for the task instance. This name appears in the task's output.
Description: Specifies comments for the tasks.
| Table of Contents |