The task webxmlmerge provides a convenient way
to inject external definitions into a web deployment descriptor
(web.xml
) from an Ant build. It's primary intended use is to
include the definition of the Cactus redirectors into the application's
descriptor to enable testing the application with Cactus.
Name | Description | Required |
---|---|---|
srcfile | The original deployment descriptor. | Yes |
destfile | The destination file. | Yes |
mergefile | The descriptor containing the definitions that should be merged into the descriptor. | Yes |
encoding | The character encoding of the destination file. If this attribute is ommitted, the character encoding of the source file will be applied. | No |
force |
By default the task checks the modification times of the files
before performing the merge. Set this attribute to
false to perform the merge regardless of whether the
destination file seems to be up to date.
|
No |
indent | Whether the resulting XML should be indented when written to the destination file. | No, the default is false |
xmlcatalog
element can be used to perform Entity and
URI resolution. This is a built-in Ant type. See the
Ant documentation for details.
xmlcatalog
element. Further, actually
specifying it will disable the default behaviour, and you'll need
to provide the web-app DTDs yourself.
<webxmlmerge srcfile="${src.conf.dir}/web.xml" destfile="${build.conf.dir}/web.xml" mergefile="${cactus.ant.home}/confs/web.xml"/>
xmlcatalog
element:
<webxmlmerge srcfile="${src.conf.dir}/web.xml" destfile="${build.conf.dir}/web.xml" mergefile="${cactus.ant.home}/confs/web.xml"> <xmlcatalog> <dtd publicid="-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" location="${src.dtd.dir}/web-app_2_2.dtd"/> <dtd publicid="-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" location="${src.dtd.dir}/web-app_2_3.dtd"/> </xmlcatalog> </webxmlmerge>
xmlcatalog
by reference, so that it can also be used in other tasks (for
example to validate the descriptors). In addition, the
indent
attribute is set to yes
to achieve
better readability of the resulting descriptor.
<xmlcatalog id="j2ee.dtds"> <dtd publicid="-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" location="${src.dtd.dir}/web-app_2_2.dtd"/> <dtd publicid="-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" location="${src.dtd.dir}/web-app_2_3.dtd"/> </xmlcatalog> <webxmlmerge srcfile="${src.conf.dir}/web.xml" destfile="${build.conf.dir}/web.xml" mergefile="${cactus.ant.home}/confs/web.xml" indent="yes"> <xmlcatalog refid="j2ee.dtds"/> </webxmlmerge>