ibm.com/developerWorks
Presented by developerWorks, your source for great tutorials
To generate the
web.xml
file from the Java source, you need to use XDoclet s
webdoclet
task, as shown:
destdir="${WEBINF}" />
The
webdoclet
task is used in a Ant target called
generateDD
. The output directory
of is specified with the
webdoclet
task s
destdir
attribute
webdoclet
destdir="${dest}"
. The dest property is set in the
build.properties
file
(/tutorials/J2EEXdoclet/webdoclet/web/WEB INF).
The input files for the
webdoclet
task are specified with a fileset:
fileset
dir="${src}"
. The src property is set in the
build.properties
file
(
/tutorials/webdoclet/src
). The fileset uses a filter so that only the classes ending in
Servlet will be selected as in BasicServlet:
name="**/*Servlet.java"/>
. This is to avoid processing all of the source code
instead of just the source code that uses XDoclet tags.
The
deploymentdescriptor
subtask specifies the location for the generated
deployment descriptor using the destdir attribute:
deploymentdescriptor ...
destdir="${WEBINF}"
. The
deploymentdescriptor
is the subtask that actually
generates the
web.xml
file.
Running Ant
To run the sample Ant build file, go to the directory that contains the project files. To
run Ant, navigate to the
/tutorials/J2EEXdoclet/webdoclet
directory and type:
ant
deploy
As I stated earlier, Ant will locate
build.xml
, the default name for the build file. (You may
have to adjust your
build.properties
files.) For this example, here is the command line
output you should expect:
C:\tutorials\J2EEXdoclet\webdoclet>ant deploy
Buildfile: build.xml
init:
[mkdir] Created dir: C:\tutorials\J2EEXdoclet\webdoclet\tmp\war
Page 18 of 49
Enhance J2EE component reuse with XDoclets
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved