Chapter 2. A first Ant build

 

This chapter covers:

  • 2.1 Defining our first project
  • 2.2 Step zero: creating the project directory
  • 2.3 Step one: verifying the tools are in place
  • 2.4 Step two: writing your first Ant build file
  • 2.5 Step three: running your first build
  • 2.6 Step four: imposing structure
  • 2.7 Step five: running our program
  • 2.8 Ant command-line options
  • 2.9 Examining the final build file
  • 2.10 Running the build under an IDE
  • 2.11 Summary

Let’s start this gentle introduction to Ant with a demonstration of what it can do. The first chapter described how Ant views a project: a project contains targets, each of which is a set of actions—tasks—that perform part of the build. Targets can depend on other targets, all of which are declared in an XML file, called a build file.

This chapter will show you how to use Ant to compile and run a Java program, introducing Ant along the way.

2.1. Defining our first project

Compiling and running a Java program under Ant will introduce the basic concepts of Ant—its command line, the structure of a build file, and some of Ant’s tasks.

Table 2.1 shows the steps we will walk though to build and run a program under Ant.

2.2. Step zero: creating the project directory

2.3. Step one: verifying the tools are in place

2.4. Step two: writing your first Ant build file

2.5. Step three: running your first build

2.6. Step four: imposing structure

2.7. Step five: running our program

2.8. Ant command-line options

2.9. Examining the final build file

2.10. Running the build under an IDE

2.11. Summary