Running BeanDoc on Your Configuration Files
When you build BeanDoc, it places the spring-beandoc.jarfile and all of its runtime depend-
encies in the target/distdirectory under the project root. Whenever you use the tool, you
must ensure that all of the runtime dependencies are available. Two of those are Spring JAR
files, so if you already have a recent spring.jarfile in your project, you probably don’t need to
duplicate them.
BeanDoc can be invoked from the command line, through Java code, or as an Ant task—
which is supplied with BeanDoc and is in the spring-beandoc.jarfile. Since using Ant is the
most common way to interact with it, that’s what we’ll describe here. The Ant option is perfect
for this type of task, since you need to set it up only once and can make the beandoctarget a
dependency of your main build target. That way, every time you build your code, the docu-
mentation and object graphs are up to date.
Listing A-1 shows a simple build.xmlfile defining the task and a target to run BeanDoc on
your application.
Listing A-1.build.xml File for BeanDoc
<project name="spring-beandoc-sample" basedir="." default="beandoc">
<!-- sets up BeanDoc classpath -->
<path id="main-classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="init">
<taskdef name="beandoc"
classname="org.springframework.beandoc.client.AntTask">
<classpath refid="main-classpath"/>
</taskdef>
<mkdir dir="${output.dir}" />
</target>
<target name="beandoc" depends="init">
<beandoc outputDir="${output.dir}">
<fileset dir="${conf.dir}">
<include name="*Context.xml"/>
<include name="*-servlet.xml"/>
</fileset>
</beandoc>
</target>
</project>
APPENDIX A ■DOCUMENTING YOUR MVC APPLICATION 373
584X_Ch13_AppA_FINAL 1/30/06 1:13 PM Page 373