Regenerating Files That Have Changed
Problem
You want to control when files are regenerated.
Solution
Add the force
attribute to any Ant Doclet task.
Discussion
Ant XDoclet tasks, by default, perform dependency-checking on generated files. These checks only regenerate files that are out of date with respect to their corresponding template files. There are times, though, that you may wish to force all generated files to be regenerated. For example, you may wish to do this if you are performing a clean build of the project from scratch, or you have upgraded to a newer version of XDoclet.
All XDoclet tasks, such as ejbdoclet
, define an
attribute called force
. This attribute tells the
XDoclet task whether to perform dependency-checking before generating
a file. A value of “true” tells the
XDoclet task to force generation of all files. A value other than
“true” tells the XDoclet task to
perform dependency-checking before generating a file. A dependency
check simply looks at the timestamp of a source or template file and
compares it with the timestamp of its generated files. If a source or
template file has a timestamp that is greater than its generated
files, then the files are regenerated. Example 9-1
shows how to add the force
attribute to any
XDoclet task.
Example 9-1. Using the force attribute to control dependency-checking
<target name="generate.ejb">
<ejbdoclet
ejbspec="2.0"
destdir="${dir.generated.src}"
force="${force.generation}"> <!-- subtasks left out for brevity --> </ejbdoclet> ...
Get Java Extreme Programming Cookbook 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.