Developing Web Applications With Ant by Richard Hightower - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

By Richard Hightower, CTO, Trivera Technologies

Another Neat Tool (Ant) enables you to automate the build deploy process of your server-side Java Web components, such as custom tags, servlets, and JSPs. In this chapter, we show you how to write Ant build files, and explain how to automate the build and deploy process for your Web component development.

Ant's easy-to-use XML-based syntax overcomes many of the issues with make. Unlike using shell scripts and batch files to create build scripts, Ant works cross-platform and is geared toward Java build files. Ant gets its cross-platform support by relying on Java for file access, compilation, and other tasks.

Ant is extensible through its support for scripting (Jython and NetRexx, among others), Java custom tasks, and the ability to call OS commands, executables, and shell scripts via an Ant exec task (normally a lastresort measure). Ant makes continuous integration possible for server-side components with its automated build script and integration with JUnit, a unit-testing framework for Java.

Developing in the J2EE environment can be tricky, with its multitude of deployment descriptors and configuration files. In addition, these files often need to be configured and reconfigured for each deployment environment, and for each application the components will be deployed in and for each phase in the development process. After all, the advantage of using components is that they can be reused by many applications--and you are not going to deploy your application and components without going through the full development cycle. You may want to deploy to different servers; say you need to deploy to your development server (maybe a local Windows box), then your integration server (Solaris or Linux), then to the QA server--and with some good fortune one day, to your production server. Now, each of these application server instances will likely use different instances of your datastore (MySQL, SQL Server, Oracle, etc.). Then add the fact that you may be trying to deploy your components to different application servers, and your build process can quickly become too complex not to automate.

Ant comes to the rescue, allowing you to automate your build and deploy process. Ant lets you manage the complexities of component development and make continuous integration with J2EE development possible.

Note
Ant was developed by the Apache Software Foundation as part of its Jakarta project. Ant 1.5 is distributed with the Apache Software License version 1.1, and you can download it at http://jakarta.apache.org/ant/index.html.

This chapter starts out with a quick tour of Ant. For those of you who want an easier time of it, we present a step-by-step tutorial to using Ant with a limited set of Ant built-in tasks.