Home

 

Building a simple Java application

We created a simple build file that compiles the Java source for our HelloAnt application and generates a JAR file with the result. The build file is called build.xml, which is the default name assumed by Ant if no build file name is supplied.

The example simple build file has the following targets:

init: Performs build initialization tasks. All other targets depend upon this target.

compile: Compiles Java source into class files.

dist: Creates the deliverable JAR for the module, and depends upon the compile target.

clean: Removes all generated files. Used to force a full build.

Each Ant build file can have a default target. This target is executed if Ant is invoked on a build file and no target is supplied as a parameter. In our example, the default target is dist, as specified in the <project> tag. The dependencies between the targets are illustrated in Figure | 5-10.

Figure 25-10 Ant example dependencies

ibm.com/redbooks