Contact at or 8097636691
Responsive Ads Here

Monday, 25 June 2018

Ant - Extending Ant

Ant comes with a predefined set of tasks, however you can create your own tasks, as shown in the example below.
Custom Ant Tasks should extend the class and should extend the execute() method. Below is a simple example −
package com.tutorialspoint.ant;


public class MyTask extends Task {
   String message;
   public void execute() throws BuildException {
      log("Message: " + message, Project.MSG_INFO);
   public void setMessage(String message) {
      this.message = message;
To execute the custom task, you need to add the following to the Hello WorldFax web application −
<target name = "custom">
   <taskdef name = "custom" classname = "com.tutorialspoint.ant.MyTask" />
   <custom message = "Hello World!"/>
Executing the above custom task prints the message 'Hello World!'
c:\>ant custom
[custom] Message : Hello World!
elapsed: 0.2 sec
This is just a simple example, you can use the power of Ant to do whatever you want to improve your build and deployment process.

No comments:

Post a Comment