Creating an XDoclet xdoclet.xml File
Problem
You need to create a
new XDoclet xdoclet.xml file for a custom code
generator.
Solution
Mark up your sub tasks with @ant.element tags and
your tag handler classes with @xdoclet.taghandler
tags. Add an Ant target to your buildfile that executes
XDoclet’s template subtask with
XDoclet’s xdoclet-xml.xdt
template file.
Discussion
XDoclet 1.2 code generators require a deployment descriptor named
xdoclet.xml. This file defines the namespace for
an XDoclet tag handler class used in a template file, and defines the
subtasks that are valid for a single XDoclet task. The file must
exist in the meta-inf directory of your code
generator’s JAR file. The JAR file is known as an
XDoclet module. Modules are discussed in more detail in the next
recipe.
Example 9-14 shows how to mark up an XDoclet subtask.
The only tag needed is an @ant.element tag. This
tag defines two mandatory attributes: name and
parent. The name attribute
specifies the subtask name to use in the Ant buildfile. The
parent attribute specifies the Ant XDoclet task
that is allowed to execute the subtask. Remember that we do not need
a subclass of xdoclet.DocletTask; therefore,
we use
DocletTask as the parent.
Example 9-14. Marked-up XDoclet subtask
/*** @ant.element* name="junitperf"* parent="xdoclet.DocletTask"* * @author Brian M. Coyner */
Example 9-15 shows how to mark up an XDoclet tag
handler class. The only tag needed is an
@xdoclet.taghandler tag with the mandatory
attribute namespace ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access