O'Reilly logo

Java Extreme Programming Cookbook by Brian M. Coyner, Eric M. Burke

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. Prepare the development environment by creating output directories.

  2. Compile out-of-date code.

  3. Package the code into a deployable unit (JAR, WAR, or EAR).

  4. Execute the JUnit tests.[42]

  5. 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:

  1. Prepare the development environment by creating output directories.

  2. Run XDoclet to regenerate out-of-date generated source files.

  3. Compile out-of-date code.

  4. Package the code into a deployable unit (JAR, WAR, or EAR).

  5. Execute the JUnit tests.

  6. 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required