Apache Ant Tasks
Task is a piece of code that can be executed. A task can have multiple attributes and each task has a common structure. A common structure consists of task-name, attributes etc. See an example below.
A task may comprises of:
Apache Ant tasks are categories into two category.
Apache Ant Predefined (Built-In) Tasks
Tasks those are provided by Apache Ant itself in it's library are known as built-in tasks. Apache ant provides large number of built-in tasks which can be used to execute distinguish tasks. A list is given below.
and many more...
Tasks which are used to compress and uncompress data are know as archive tasks. Some common built-in archived tasks are tabled below.
|JDepend||It is used to invoke JDepend parser.|
Tasks which are used to compile source files are know as compile tasks. Some common built-in compile tasks are tabled below.
|Depend||Determines which class files are out of date with respect to their resources.|
|Javac||It compiles the source file.|
|JspC||It runs the JSP compiler.|
|NetRexxC||It compiles a NetRexx source file.|
|Rmic||Runs the rmic compiler.|
Tasks which are used to execute of run applications are know as execution tasks. Some common built-in execution tasks are tabled below.
|Ant||It runs Ant on specified buildfile.|
|AntCall||It runs another target in the same buildfile.|
|Apply||It executes a system command.|
|Java||Executes a Java class.|
|Parallel||A container task that can contain other ant tasks.|
|Sleep||It suspends execution for the specified time.|
Tasks which are related to handle file operations are know as file tasks. Some common built-in file tasks are tabled below.
|Chmod||It changes permission of the file.|
|Chown||It changes ownership of the file.|
|Concat||It concatenates multiple files.|
|Copy||It copies file to new destination.|
|Delete||Delete a file.|
|Mkdir||It creates a directory.|
Concatenate a single file, appending if the destination file exists
To use tasks, first we need to create a project by using <project> tag. After that create a target to group tasks by using <target> tag. Then we can execute tasks by putting tasks inside the target tag. Let's see an example, Java task is created here by using <java> tag.
Apache Ant allows us to write our own tasks. It is pretty easy to write own tasks. Some required steps are given below. Consider the following points.