Package org.apache.tools.ant.taskdefs
Class Ant
- java.lang.Object
- 
- org.apache.tools.ant.ProjectComponent
- 
- org.apache.tools.ant.Task
- 
- org.apache.tools.ant.taskdefs.Ant
 
 
 
- 
- All Implemented Interfaces:
- java.lang.Cloneable
 
 public class Ant extends Task Build a sub-project.<target name="foo" depends="init"> <ant antfile="build.xml" target="bar" > <property name="property1" value="aaaaa" /> <property name="foo" value="baz" /> </ant> </target> <target name="bar" depends="init"> <echo message="prop is ${property1} ${foo}" /> </target>- Since:
- Ant 1.1
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classAnt.ReferenceHelper class that implements the nested <reference> element of <ant> and <antcall>.static classAnt.TargetElementHelper class that implements the nested <target> element of <ant> and <antcall>.
 - 
Field Summary- 
Fields inherited from class org.apache.tools.ant.ProjectComponentdescription, location, project
 
- 
 - 
Method SummaryModifier and Type Method Description voidaddConfiguredTarget(Ant.TargetElement t)Add a target to this Ant invocation.voidaddPropertyset(PropertySet ps)Add a set of properties to pass to the new project.voidaddReference(Ant.Reference ref)Add a Reference element identifying a data type to carry over to the new project.PropertycreateProperty()Property to pass to the new project.voidexecute()Do the execution.protected java.lang.StringgetDefaultBuildFile()Get the default build file name to use when launching the task.protected ProjectgetNewProject()Get the (sub)-Project instance currently in use.voidhandleErrorFlush(java.lang.String errorOutputToFlush)Handle error output.voidhandleErrorOutput(java.lang.String errorOutputToHandle)Handle error output.voidhandleFlush(java.lang.String toFlush)Handles output.inthandleInput(byte[] buffer, int offset, int length)Handles input.voidhandleOutput(java.lang.String outputToHandle)Handles output.voidinit()Creates a Project instance for the project to call.voidsetAntfile(java.lang.String antFile)The build file to use.voidsetDir(java.io.File dir)The directory to use as a base directory for the new Ant project.voidsetInheritAll(boolean value)If true, pass all properties to the new Ant project.voidsetInheritRefs(boolean value)If true, pass all references to the new Ant project.voidsetOutput(java.lang.String outputFile)Set the filename to write the output to.voidsetTarget(java.lang.String targetToAdd)The target of the new Ant project to execute.voidsetUseNativeBasedir(boolean b)Whether the basedir of the new project should be the same one as it would be when running the build file directly - independent of dir and/or inheritAll settings.- 
Methods inherited from class org.apache.tools.ant.TaskbindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 - 
Methods inherited from class org.apache.tools.ant.ProjectComponentclone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
- 
 
- 
- 
- 
Constructor Detail- 
Antpublic Ant() simple constructor
 - 
Antpublic Ant(Task owner) create a task bound to its creator- Parameters:
- owner- owning task
 
 
- 
 - 
Method Detail- 
setUseNativeBasedirpublic void setUseNativeBasedir(boolean b) Whether the basedir of the new project should be the same one as it would be when running the build file directly - independent of dir and/or inheritAll settings.- Parameters:
- b- boolean
- Since:
- Ant 1.8.0
 
 - 
setInheritAllpublic void setInheritAll(boolean value) If true, pass all properties to the new Ant project. Defaults to true.- Parameters:
- value- if true pass all properties to the new Ant project.
 
 - 
setInheritRefspublic void setInheritRefs(boolean value) If true, pass all references to the new Ant project. Defaults to false.- Parameters:
- value- if true, pass all references to the new Ant project
 
 - 
initpublic void init() Creates a Project instance for the project to call.
 - 
handleOutputpublic void handleOutput(java.lang.String outputToHandle) Handles output. Send it the the new project if is present, otherwise call the super class.- Overrides:
- handleOutputin class- Task
- Parameters:
- outputToHandle- The string output to output.
- Since:
- Ant 1.5
- See Also:
- Task.handleOutput(String)
 
 - 
handleInputpublic int handleInput(byte[] buffer, int offset, int length) throws java.io.IOExceptionHandles input. Delegate to the created project, if present, otherwise call the super class.- Overrides:
- handleInputin class- Task
- Parameters:
- buffer- the buffer into which data is to be read.
- offset- the offset into the buffer at which data is stored.
- length- the amount of data to read.
- Returns:
- the number of bytes read.
- Throws:
- java.io.IOException- if the data cannot be read.
- Since:
- Ant 1.6
- See Also:
- Task.handleInput(byte[], int, int)
 
 - 
handleFlushpublic void handleFlush(java.lang.String toFlush) Handles output. Send it the the new project if is present, otherwise call the super class.- Overrides:
- handleFlushin class- Task
- Parameters:
- toFlush- The string to output.
- Since:
- Ant 1.5.2
- See Also:
- Task.handleFlush(String)
 
 - 
handleErrorOutputpublic void handleErrorOutput(java.lang.String errorOutputToHandle) Handle error output. Send it the the new project if is present, otherwise call the super class.- Overrides:
- handleErrorOutputin class- Task
- Parameters:
- errorOutputToHandle- The string to output.
- Since:
- Ant 1.5
- See Also:
- Task.handleErrorOutput(String)
 
 - 
handleErrorFlushpublic void handleErrorFlush(java.lang.String errorOutputToFlush) Handle error output. Send it the the new project if is present, otherwise call the super class.- Overrides:
- handleErrorFlushin class- Task
- Parameters:
- errorOutputToFlush- The string to output.
- Since:
- Ant 1.5.2
- See Also:
- Task.handleErrorFlush(String)
 
 - 
executepublic void execute() throws BuildExceptionDo the execution.- Overrides:
- executein class- Task
- Throws:
- BuildException- if a target tries to call itself; probably also if a BuildException is thrown by the new project.
 
 - 
getDefaultBuildFileprotected java.lang.String getDefaultBuildFile() Get the default build file name to use when launching the task.This function may be overridden by providers of custom ProjectHelper so they can easily implement their sublauncher. - Returns:
- the name of the default file
- Since:
- Ant 1.8.0
 
 - 
setDirpublic void setDir(java.io.File dir) The directory to use as a base directory for the new Ant project. Defaults to the current project's basedir, unless inheritall has been set to false, in which case it doesn't have a default value. This will override the basedir setting of the called project.- Parameters:
- dir- new directory as- File.
 
 - 
setAntfilepublic void setAntfile(java.lang.String antFile) The build file to use. Defaults to "build.xml". This file is expected to be a filename relative to the dir attribute given.- Parameters:
- antFile- the- Stringbuild file name.
 
 - 
setTargetpublic void setTarget(java.lang.String targetToAdd) The target of the new Ant project to execute. Defaults to the new project's default target.- Parameters:
- targetToAdd- the name of the target to invoke.
 
 - 
setOutputpublic void setOutput(java.lang.String outputFile) Set the filename to write the output to. This is relative to the value of the dir attribute if it has been set or to the base directory of the current project otherwise.- Parameters:
- outputFile- the name of the file to which the output should go.
 
 - 
createPropertypublic Property createProperty() Property to pass to the new project. The property is passed as a 'user property'.- Returns:
- the created Propertyobject.
 
 - 
addReferencepublic void addReference(Ant.Reference ref) Add a Reference element identifying a data type to carry over to the new project.- Parameters:
- ref-- Referenceto add.
 
 - 
addConfiguredTargetpublic void addConfiguredTarget(Ant.TargetElement t) Add a target to this Ant invocation.- Parameters:
- t- the- TargetElementto add.
- Since:
- Ant 1.6.3
 
 - 
addPropertysetpublic void addPropertyset(PropertySet ps) Add a set of properties to pass to the new project.- Parameters:
- ps-- PropertySetto add.
- Since:
- Ant 1.6
 
 - 
getNewProjectprotected Project getNewProject() Get the (sub)-Project instance currently in use.- Returns:
- Project
- Since:
- Ant 1.7
 
 
- 
 
-