Chapter 3. Understanding Ant datatypes and properties
This chapter covers:
- 3.1 Preliminaries
- 3.2 Introducing datatypes and properties with <javac>
- 3.3 Paths
- 3.4 Filesets
- 3.5 Selectors
- 3.6 Additional Ant datatypes
- 3.7 Properties
- 3.8 Controlling Ant with properties
- 3.9 References
- 3.10 Managing library dependencies
- 3.11 Resources: Ant’s secret data model
- 3.12 Best practices
- 3.13 Summary
In the last chapter, we used Ant to build, archive, and run a Java program. Now we’re going to look at how to control that process through Ant’s datatypes and properties.
In programming language terms, Ant’s tasks represent the functionality offered by the runtime libraries. The tasks are useful only with data, the information that they need to know what to do. Java is an object-oriented language where data and functions are mixed into classes. Ant, although written in Java, differentiates between the tasks that do the work and the data they work with—data represented as datatypes. Ant also has the approximate equivalent of variables in its properties.
To pass data to tasks, you need to be able to construct and refer to datatypes and properties in a build file. As with tasks, datatypes are just pieces of XML, pieces that list files or other resources that a task can use. This chapter introduces datatypes and properties. It does go into some depth, so don’t be afraid to skip bits and return to them later. We’ll start with the basic concepts.