Chapter 3. Building Java Code
Ant is the premiere build tool for Java developers, and this chapter
focuses on the Java build process, from compiling Java code with the
javac
task through compressing and
packaging the results with tasks such as jar
and tar
.
Along the way, I'll discuss several central build issues, such as keeping
track of the build number, storing that number in a JAR file's manifest
file, getting input from the user and acting on that input, calling one
Ant target from another, creating Javadoc with the javadoc
task, and more.
Compiling Code
The javac
task compiles
Java source code. You've seen javac
at work many times in this book but haven't exhausted what this task has
to offer by any means. You can get an idea how extensive a task it is by
its huge number of attributes, shown in Table 3-1.
Table 3-1. The javac task's attributes
Attribute | Description | Required | Default |
---|---|---|---|
| Specifies where to find any bootstrap class files. | No | |
| Specifies where to find any bootstrap class files, given as a reference. | No | |
| Specifies the classpath you want to use. | No | |
| Specifies the classpath you want to use, given as a reference to a path. | No | |
| Specifies the compiler you want to use. If you
don't set this attribute, this task will use the compiler
pointed to by the | No | |
| Specifies whether or not your code should be ... |
Get Ant: The Definitive Guide, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.