此内容没有您所选择的语言版本。
7.4. Using Ant Tasks
An Ant bundle distribution file is just an Ant recipe and its associated files. As Example 1, “Simple Ant Recipe” shows, the Ant recipe is the expected
deploy.xml
file with some JBoss ON-specific elements. An Ant bundle distribution file supports more complex Ant configuration, including Ant tasks and targets.
7.4.1. Supported Ant Tasks 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
Any standard Ant task can be run as part of the Ant bundle provisioning (with the exception of
<antcall>
and <macrodef>
). This includes common commands like echo
, mkdir
, and touch
— whatever is required to deploy the content fully.
Important
The
<antcall>
element cannot be used with the Ant recipe. <antcall>
calls a target within the deploy.xml
file, which loops back to the file, which calls the <antcall>
task again, which calls the deploy.xml
file again. This creates an infinite loop.
To perform the same operations that would be done with
<antcall>
, use the <ant>
task to reference a separate XML file which contains the custom Ant targets. This is described in Section 7.4.3, “Calling Ant Targets”.
Important
The
macrodef
call, and therefore macro definitions, are not supported with Ant bundles.
Along with the standard Ant tasks, Ant bundle recipes can use optional Ant tasks:
As with other Ant tasks, the
<project>
allows a default target, which is required by the provisioning system. This is a no-op because the Ant recipe mainly defines the metadata for and identifies files used by the provisioning process. Other operations aren't necessary. This target is required by Ant, even though it is a no-op target. Use pre- and post-install targets to perform tasks with the bundle before and after it is unpacked.
For example:
<target name="main" />
<target name="main" />
Additionally, JBoss ON provisioning tasks can define both pre- and post-install targets. This allows custom tasks, like simple progress messages or setting properties.
7.4.3. Calling Ant Targets 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
As mentioned in Section 7.4.1, “Supported Ant Tasks”, using
<antcall>
does not work in an Ant bundle recipe; it self-referentially calls the <rhq:bundle>
task in an infinite loop. However, it is possible to process tasks that are outside the default target. This can be done using pre- and post install targets (Section 7.4.2, “Using Default, Pre-Install, and Post-Install Targets”).
- In
deploy.xml
for the Ant recipe, add a<rhq:deployment-unit>
element which identifies the Ant target.<rhq:deployment-unit name="jar" postinstallTarget="myExampleCall">
<rhq:deployment-unit name="jar" postinstallTarget="myExampleCall">
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Then, define the target.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Create a separate
another.xml
file in the same directory as thedeploy.xml
file. This file contains the Ant task.Copy to Clipboard Copied! Toggle word wrap Toggle overflow