Using XDoclet

XDoclet is an open source code generation engine designed for use with Ant, and you can pick it up for free at http://xdoclet.sourceforge.net/. It'll write code for you, especially deployment descriptors, and is often used for Web and EJB development. XDoclet comes with a number of Ant tasks built-in, shown in Table 9-9.

Table 9-9. The XDoclet Ant tasks

Ant task

Does this

doclet

Specifies the base class for all XDoclet Ant tasks

ejbdoclet

Specifies which EJB-specific subtasks to execute

hibernatedoclet

Specifies which Hibernate subtasks to execute

jdodoclet

Specifies which JDO-specific subtasks to execute

jmxdoclet

Specifies which JMX-specific subtasks to execute

mockdoclet

Generates mock doclet objects

portletdoclet

Specifies which portlet-specific subtasks to execute

webdoclet

Specifies which Web-specific subtasks to execute

XDoclet lets you generate code and deployment descriptors by embedding tags in your code, much like the tags you'd use for Javadoc. There are entire books written about XDoclet because it's an extensive tool. Though there's not room for that level of coverage herethis is a book about Ant, not XDocletI'll take a look at several examples creating Web and EJB applications here, giving the XDoclet story from Ant's point of view.

Developing Applications

You use the XDoclet webdoclet task to develop Web applications. The attributes of this task appear in Table 9-10, and the possible nested elements in Table 9-11.

Table 9-10. The webdoclet Ant tasks ...

Get Ant: The Definitive Guide, 2nd Edition 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.