Java 2EE and XML Development

Скачать в pdf «Java 2EE and XML Development»




Absolute path to your Ant installation




Add Java and Ant executable directories to your system path



To test your installation, go to a shell and execute the command ant from any directory. If ant is installed properly, you will see the following message (assuming no file named build.xml is found in your current directory):

Buildfile: build.xml does not exist!

Build failed.

If you see the above message when you type ant at a command line, you are now ready to construct your first build file and begin using Ant.

C.2 Creating a build file

An Ant build file is an XML document with a structure represented by figure C.1. As you see, the root node of a build file is the <project> element. Projects can contain global properties, task definitions, dynamically constructed path variables, and targets. Targets are named groupings of tasks. A target can depend on the successful execution of other targets. A target can also invoke other targets in the course of its processing. The capabilities of Ant tasks, properties, and dynamic paths make Ant an extremely powerful and flexible tool.

C.2.1 Dynamically constructed paths and file sets

One of the key features of Ant, besides the numerous built-in and optional tasks it can perform, is its ability to dynamically construct path variables at execution time, specifically a classpath. As we mentioned in the previous section, a <path> is just one type of element found in an Ant build file.

Скачать в pdf «Java 2EE and XML Development»