FileDocCategorySizeDatePackage
CallTarget.javaAPI DocApache Ant 1.707335Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.taskdefs

CallTarget

public class CallTarget extends org.apache.tools.ant.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
ant.task
name="antcall" category="control"

Fields Summary
private Ant
callee
private boolean
inheritAll
private boolean
inheritRefs
private boolean
targetSet
Constructors Summary
Methods Summary
public voidaddConfiguredTarget(Ant.TargetElement t)
Add a target to the list of targets to invoke.

param
t Ant.TargetElement representing the target.
since
Ant 1.6.3

        if (callee == null) {
            init();
        }
        callee.addConfiguredTarget(t);
        targetSet = true;
    
public voidaddPropertyset(org.apache.tools.ant.types.PropertySet ps)
Set of properties to pass to the new project.

param
ps the PropertySet to pass.
since
Ant 1.6

        if (callee == null) {
            init();
        }
        callee.addPropertyset(ps);
    
public voidaddReference(Ant.Reference r)
Reference element identifying a data type to carry over to the invoked target.

param
r the specified Ant.Reference.
since
Ant 1.5

        if (callee == null) {
            init();
        }
        callee.addReference(r);
    
public PropertycreateParam()
Create a new Property to pass to the invoked target(s).

return
a Property object.

        if (callee == null) {
            init();
        }
        return callee.createProperty();
    
public voidexecute()
Delegate the work to the ant task instance, after setting it up.

throws
BuildException on validation failure or if the target didn't execute.

        if (callee == null) {
            init();
        }
        if (!targetSet) {
            throw new BuildException(
                "Attribute target or at least one nested target is required.",
                 getLocation());
        }
        callee.setAntfile(getProject().getProperty("ant.file"));
        callee.setInheritAll(inheritAll);
        callee.setInheritRefs(inheritRefs);
        callee.execute();
    
public voidhandleErrorFlush(java.lang.String output)
Handle error output. Send it the the new project if is present, otherwise call the super class.

param
output The string to output.
see
Task#handleErrorFlush(String)
since
Ant 1.5.2

        if (callee != null) {
            callee.handleErrorFlush(output);
        } else {
            super.handleErrorFlush(output);
        }
    
public voidhandleErrorOutput(java.lang.String output)
Handle error output. Send it the the new project if is present, otherwise call the super class.

param
output The string to output.
see
Task#handleErrorOutput(String)
since
Ant 1.5

        if (callee != null) {
            callee.handleErrorOutput(output);
        } else {
            super.handleErrorOutput(output);
        }
    
public voidhandleFlush(java.lang.String output)
Handles output. Send it the the new project if is present, otherwise call the super class.

param
output The string to output.
see
Task#handleFlush(String)
since
Ant 1.5.2

        if (callee != null) {
            callee.handleFlush(output);
        } else {
            super.handleFlush(output);
        }
    
public inthandleInput(byte[] buffer, int offset, int length)
Handles input. Deleate to the created project, if present, otherwise call the super class.

param
buffer the buffer into which data is to be read.
param
offset the offset into the buffer at which data is stored.
param
length the amount of data to read.
return
the number of bytes read.
exception
IOException if the data cannot be read.
see
Task#handleInput(byte[], int, int)
since
Ant 1.6

        if (callee != null) {
            return callee.handleInput(buffer, offset, length);
        }
        return super.handleInput(buffer, offset, length);
    
public voidhandleOutput(java.lang.String output)
Handles output. Send it the the new project if is present, otherwise call the super class.

param
output The string output to output.
see
Task#handleOutput(String)
since
Ant 1.5

        if (callee != null) {
            callee.handleOutput(output);
        } else {
            super.handleOutput(output);
        }
    
public voidinit()
Initialize this task by creating new instance of the ant task and configuring it by calling its own init method.

        callee = new Ant(this);
        callee.init();
    
public voidsetInheritAll(boolean inherit)
If true, pass all properties to the new Ant project. Defaults to true.

param
inherit boolean flag.


                          
        
       inheritAll = inherit;
    
public voidsetInheritRefs(boolean inheritRefs)
If true, pass all references to the new Ant project. Defaults to false.

param
inheritRefs boolean flag.

        this.inheritRefs = inheritRefs;
    
public voidsetTarget(java.lang.String target)
Set target to execute.

param
target the name of the target to execute.

        if (callee == null) {
            init();
        }
        callee.setTarget(target);
        targetSet = true;