O'Reilly logo

Ant: The Definitive Guide by Jesse Tilly, Eric M. Burke

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Ant DataTypes

In the previous chapter’s buildfile example, you saw the fileset DataType being used to identify groups of files to copy in order to deploy the irssibot application. DataTypes are important when using Ant, and fileset is just one of the many available to you:

argument

Passes command-line arguments to programs that you invoke from an Ant buildfile.

environment

Specifies environment variables to pass to an external command or program that you execute from an Ant buildfile.

filelist

Defines a named list of files that do not necessarily need to actually exist.

fileset

Defines a named list of files that must actually exist.

patternset

Groups a set of patterns together.

filterset

Groups a set of filters together.

path

Specifies paths (such as a classpath) in a way that is portable between operating systems.

mapper

Defines a complex relationship between a set of input files and a set of output files.

Let’s dig in and learn more about these fundamental Ant DataTypes. They are building blocks used by tasks and are essential to using Ant effectively. In this chapter, we’ll talk about each DataType in detail. Before doing that, however, we discuss briefly how DataTypes fit into Ant’s overall design, and explain the notation used in this chapter to describe the attributes for the different DataTypes.

DataTypes Defined

Ant DataTypes are found in the org.apache.tools.ant.types package, usually extending from the org.apache.tools.ant.types.DataType base class. EnumeratedAttribute, Commandline, Environment, and Reference are also treated as DataTypes, although they do not extend from DataType. Figure 4-1 contains a basic UML class diagram illustrating this aspect of Ant’s design.

Ant DataTypes

Figure 4-1. Ant DataTypes

The base class, org.apache.tools.ant.ProjectComponent, provides logging functionality as well as access to the Project object. Not shown here, ProjectComponent is also the base class for every Ant task. These tasks are detailed in Chapter 7 and Chapter 8.

While the class diagram helps to explain what DataTypes are, understanding the internal structure of Ant is rarely necessary. In most cases you simply want to write buildfiles and use Ant. For this reason, the remainder of this chapter focuses on how these types are used, rather than how their internal implementation works.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required