org.apache.tools.ant.taskdefs

Class CallTarget


public class CallTarget
extends Task

Call another target in the same project.
    <target name="foo">
      <antcall target="bar">
        <param name="property1" value="aaaaa" />
        <param name="foo" value="baz" />
       </antcall>
    </target>

    <target name="bar" depends="init">
      <echo message="prop is ${property1} ${foo}" />
    </target>
 

This only works as expected if neither property1 nor foo are defined in the project itself.

Since:
Ant 1.2

Field Summary

Fields inherited from class org.apache.tools.ant.Task

description, location, target, taskName, taskType, wrapper

Fields inherited from class org.apache.tools.ant.ProjectComponent

project

Method Summary

void
addConfiguredTarget(Ant.TargetElement t)
Add a target to the list of targets to invoke.
void
addPropertyset(PropertySet ps)
Set of properties to pass to the new project.
void
addReference(Ant.Reference r)
Reference element identifying a data type to carry over to the invoked target.
Property
createParam()
Create a new Property to pass to the invoked target(s).
void
execute()
Delegate the work to the ant task instance, after setting it up.
void
handleErrorFlush(String output)
void
handleErrorOutput(String output)
void
handleFlush(String output)
int
handleInput(byte[] buffer, int offset, int length)
void
handleOutput(String output)
void
init()
Initialize this task by creating new instance of the ant task and configuring it by calling its own init method.
void
setInheritAll(boolean inherit)
If true, pass all properties to the new Ant project.
void
setInheritRefs(boolean inheritRefs)
If true, pass all references to the new Ant project.
void
setTarget(String target)
Set target to execute.

Methods inherited from class org.apache.tools.ant.Task

execute, getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType

Methods inherited from class org.apache.tools.ant.ProjectComponent

getProject, log, log, setProject

Method Details

addConfiguredTarget

public void addConfiguredTarget(Ant.TargetElement t)
Add a target to the list of targets to invoke.
Parameters:
t - Ant.TargetElement representing the target.
Since:
Ant 1.6.3

addPropertyset

public void addPropertyset(PropertySet ps)
Set of properties to pass to the new project.
Parameters:
ps - the PropertySet to pass.
Since:
Ant 1.6

addReference

public void addReference(Ant.Reference r)
Reference element identifying a data type to carry over to the invoked target.
Parameters:
r - the specified Ant.Reference.
Since:
Ant 1.5

createParam

public Property createParam()
Create a new Property to pass to the invoked target(s).
Returns:
a Property object.

execute

public void execute()
            throws BuildException
Delegate the work to the ant task instance, after setting it up.
Overrides:
execute in interface Task
Throws:
BuildException - on validation failure or if the target didn't execute.

handleErrorFlush

public void handleErrorFlush(String output)
Overrides:
handleErrorFlush in interface Task
Since:
Ant 1.5.2

handleErrorOutput

public void handleErrorOutput(String output)
Overrides:
handleErrorOutput in interface Task
Since:
Ant 1.5

handleFlush

public void handleFlush(String output)
Overrides:
handleFlush in interface Task
Since:
Ant 1.5.2

handleInput

public int handleInput(byte[] buffer,
                       int offset,
                       int length)
            throws IOException
Overrides:
handleInput in interface Task
Since:
Ant 1.6

handleOutput

public void handleOutput(String output)
Overrides:
handleOutput in interface Task
Since:
Ant 1.5

init

public void init()
Initialize this task by creating new instance of the ant task and configuring it by calling its own init method.
Overrides:
init in interface Task

setInheritAll

public void setInheritAll(boolean inherit)
If true, pass all properties to the new Ant project. Defaults to true.
Parameters:
inherit - boolean flag.

setInheritRefs

public void setInheritRefs(boolean inheritRefs)
If true, pass all references to the new Ant project. Defaults to false.
Parameters:
inheritRefs - boolean flag.

setTarget

public void setTarget(String target)
Set target to execute.
Parameters:
target - the name of the target to execute.

Copyright B) 2000-2008 Apache Software Foundation. All Rights Reserved.