Setting Up Ant to Run XDoclet
Problem
You want to integrate file generation into the Ant build process.
Solution
Modify your Ant buildfile to create the directory structure as
specified in the previous recipe and execute an
xdoclet.DocletTask
or subclass. This recipe
creates a
task definition for
xdoclet.modules.ejb.EjbDocletTask
and names it
ejbdoclet
.
Discussion
A successful XP project understands the need for continuous integration. Continuous integration means a successful build of the project, including complete generation of all out-of-date generated files and 100% passing unit tests. With that said, here’s how generating source files improves the continuous integration process. Here is a typical Ant build process:
Prepare the development environment by creating output directories.
Compile out-of-date code.
Package the code into a deployable unit (JAR, WAR, or EAR).
Execute the JUnit tests.[42]
Deploy to a server.
If any task fails the build should stop and a friendly message should be reported. Code generation adds one more step to this process:
Prepare the development environment by creating output directories.
Run XDoclet to regenerate out-of-date generated source files.
Compile out-of-date code.
Package the code into a deployable unit (JAR, WAR, or EAR).
Execute the JUnit tests.
Deploy to a server.
Adding the code-generation step requires modifying the Ant buildfile.
The first step is to define a task definition for an
xdoclet.DocletTask
task. This recipe uses the
xdoclet.modules.ejb.EjbDocletTask ...
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.