Automation with Apache Ant
If you are changing your web application periodically and have to perform these various
steps for deployment often, you will probably want to automate the process, rather than
retype the jar
(and maybe copy
/cp
) command each time. We show you how
to do so using Ant, an Apache Software Foundation build tool that is also used in Chapter 9. Of course, you can also use any other tool you
like, such as make
, Perl, or a shell script or batch
file, but Ant is the standard tool for this purpose in the Java and Tomcat communities, so
it's probably good to know the rudiments of Ant.
Ant automates the running of other programs. More precisely, Ant can run non-Java programs, but benefits from being able to do a great deal of processing just by running Java classes. Because Ant is written in Java, it already has a JVM available, so running other Java functions (including a Java compiler) is pretty fast, as the JVM is already fired up. Ant also comes with a large library of built-in tasks for common operations, including dealing with TAR, JAR, ZIP, GZIP, and other file formats—usually without resorting to running external programs. That is, it contains OS portable Java classes that can read and write files in these and other formats, as well as copying files, compiling Java programs (including servlets), and much more.
Ant reads build files written in XML that are typically named build.xml[20] for its directions. An Ant build file contains one project definition and any ...
Get Tomcat: 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.