Core Tasks

We’ve already used a few of the core tasks included with Ant in our earlier examples. Our compile target uses the javac task, which invokes the Java compiler, and our archive target uses the jar task, which creates a jar archive from a set of files. In addition to these Java-specific tasks, we’ve also seen some general-purpose tasks, like the mkdir task that creates a directory and the delete task for deleting files and directories.

Many, many other tasks bundled with the Ant distribution can be combined in a virtually infinite set of combinations to do what you need to do in your development process. We don’t intend to document all of them here—again, for complete coverage of the core Ant tasks, go to the Ant project site (http://ant.apache.org) and pick up Ant: The Definitive Guide (O’Reilly). In the following sections, we briefly discuss some general functional areas that are encountered in nearly every development project and some of the common ways that Ant supports these needs with its core tasks. These tasks are the workhorse tasks in Ant that you’ll find yourself using over and over again.

File and Directory Tasks

At the heart of any software development effort is the need to do things to files and directories. Files need to be moved or copied from one place to another, directories need to be created or deleted, sets of files need to be pulled together into archives in various formats. Naturally, Ant provides numerous built-in tasks that support these needs. ...

Get Java Enterprise in a Nutshell, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.