Using Ant for the Configuration

Of course, just putting the tags in the comment section doesn't do much until we combine it with Ant and XDoclet. In fact, we will need a specific task called webdoclet and one of its subtasks called deploymentdescriptor. There are a couple paths that you will need to know before looking at the build script. These are:

Here's an example task to handle the conversion of the deployment descriptor tags:

<'?xml version="l.0" ?>
<project default="deploy">
<path >
<fileset dir="/usr/local/resin/lib"/> </path>
<path >
<path ref >
<fileset dir="/usr/local/xdoclet/lib">
<include name="*.jar"/> </fileset>
<target name= "init">
<mkdir dir="./tmp/war" />
<mkdir dIi-"./web/WEB-INF/cl asses" /> </target>
<target >
<javac srcdir="./src" destdir="./web/WEB-INF/classes" debug="true" deprecation="true"> <classpath ref />
<target >
classname="xdoclet. moduels.web.WebDocletTask" classpathref="xdocpath"
<webdoclet destdir="./web/WEB -INF/classes"> <fileset dir="./src">
<include name="* */*" /> </fileset>
<deploymentdescriptor servletspec="2.3" destdir="./web/WEB-INF" /> </webdoclet>
<target depends="init, compile, generateDD">
<war defile="Jtmp/war/example.war" webxml="./web/WEB-INF/web.xml"> <fileset dir="./web">
<exclude name="* */build.xml" /> <exclude name="**/*.bat" />
<exclude name="* */web.xml" /> <exclude name="**/*.java" />
<exclude name="**/*.class" /> </fileset>
<lib dir="./web/WEB-INF/lib"/>
<classes dir="./web/WEB-INF/classes"> <exclude name="* */*.Java"/> </classes>
<target depends="package">
<copy file="./tmp/war/example. war" todir="/usr/local/resin/webapps" /> </target>

So what have we done in this build script? First we needed to accomplish two tasks. The first was to generate the deployment descriptor using the <webdoclet> task. Since webdoclet isn't a common task with Ant, we needed to define it using the <taskdef> element. Next, we defined where XDoclet's library files can be found so that Ant will be able to find the class that actually implements webdoclet. Finally, we added the <webdoclet> task, which will process all files within the /src directory having as part of their filename. The resulting deployment descriptor will be placed in the directory ./web/WEB-INF.

After the deployment descriptor is created, the build script will compile the servlet, produce a WAR file, and deploy it to the webapps directory of the app server. Once Ant has finished with the processing of the files, you should have a successful build. At this point, you can browse to the app server and see the contents of your database displayed.