Apache Ant Tasks Outside AntApache Ant provides rich set of tasks to perform buildfile operations therefore allows us to implement these tasks outside the Ant. It means we can execute tasks using Java programs too. Implementing Ant using Java is pretty easy. We just need to import Project, Target and Task name packages in Java source file. For example: Creating outside Ant has it?s advantage and disadvantages given below. Advantages
DisadvantagesWe need to include Ant?s library if Java source is implementing it. The ant.jar file need to be located into lib path. Not easy to modify, it requires lots of time and effort. Although being an open source and having world class community it will help to resolve, but code written in Java is not easy to alter after a long time. Ant Java ExampleSuppose we want to implement a Task unzip using Java code which requires zipfilepath and destinationDir attributes/parameters. To implement unzip task we need to import org.apache.tools.ant.taskdefs.Expand package in source file. Look at the source of the example given below. Next TopicApache Ant Argument Processor |