Cari di Apache Ant 
    Apache Ant Tutorial
Daftar Isi
(Sebelumnya) AntANTLR (Berikutnya)
Apache Ant Tasks

AntCall

AntCall

Description

Call another target within the same buildfile optionallyspecifying some properties (params in this context). Thistask must not be used outside of a target.

By default, all of the properties of the current project will beavailable in the new project. Alternatively, you canset the inheritAll attribute to false and only"user" properties (i.e., those passed on the command-line)will be passed to the new project. In either case, the set ofproperties passed to the new project will override the properties thatare set in the new project (See also the property task).

You can also set properties in the new project from the old projectby using nested param tags. These properties are always passedto the new project and any project created in that projectregardless of the setting of inheritAll. This allows you toparameterize your subprojects. Properties defined on the command linecan not be overridden by nested <param> elements.

When more than one nested <param> element would set a property of the same name, the one declared last will win. This is for backwards compatibility reasons even so it is different from the way <property> tasks in build files behave.

Nested <reference>; elements canbe used to copy references from the calling project to the newproject, optionally under a different id. References taken fromnested elements will override existing references that have beendefined outside of targets in the new project - but not those definedinside of targets.

When a target is invoked by antcall, all of its dependent targets willalso be called within the context of any new parameters. For example. ifthe target "doSomethingElse" depended on the target "init", then theantcall of "doSomethingElse" will call "init" during the call.Of course, any properties defined in the antcall task or inherited from the calling targetwill be fixed and not overridable in the init task--or indeed in the "doSomethingElse" task.

The called target(s) are run in a new project; be aware that thismeans properties, references, etc. set by called targets will notpersist back to the calling project.

If the build file changes after you've started the build, thebehavior of this task is undefined.

Parameters

Attribute Description Required
target The target to execute. Yes
inheritAll If true, pass all properties to the new Apache Ant project. Defaults to true. No
inheritRefs If true, pass all references to the new Ant project. Defaults to false. No

Note on inheritRefs

<antcall> will not override existing references,even if you set inheritRefs to true. As the called buildfiles is the same build file as the calling one, this means it willnot override any reference set via an id attribute atall. The only references that can be inherited by the child projectare those defined by nested <reference> elements orreferences defined by tasks directly (not using the idattribute).

Parameters specified as nested elements

param

Specifies the properties to set before running the specified target. See property for usage guidelines.
These properties become equivalent to properties you define onthe command line. These are special properties and they will always get passeddown, even through additional <*ant*> tasks with inheritall set tofalse (see above).

reference

Used to choose references that shall be copied into the new project,optionally changing their id.

Attribute Description Required
refid The id of the reference in the calling project. Yes
torefid The id of the reference in the new project. No, defaults to the value of refid.

propertyset

You can specify a set of properties to be copied into the newproject with propertysets.

since Ant 1.6.

target

You can specify multiple targets using nested <target> elementsinstead of using the target attribute. These will be executed as ifAnt had been invoked with a single target whose dependencies are thetargets so specified, in the order specified.

Attribute Description Required
name The name of the called target. Yes

since Ant 1.6.3.

Examples

<target name="default">  <antcall target="doSomethingElse"> <param name="param1" value="value"/>  </antcall></target><target name="doSomethingElse">  <echo message="param1=${param1}"/></target>

Will run the target 'doSomethingElse' and echo 'param1=value'.

<antcall ... >  <reference refid="path1" torefid="path2"/></antcall>

will copy the parent's definition of path1 into thenew project using the id path2.

(Sebelumnya) AntANTLR (Berikutnya)