This class also encapsulates methods which allow files to be referred to using abstract path names which are translated to native system file paths at runtime.
Modifier and Type | Class and Description |
---|---|
private static class |
Modifier and Type | Field and Description |
---|---|
private File | baseDir
Project base directory. |
private ClassLoader | coreLoader
The Ant core classloader--may be |
private InputStream | defaultInputStream
The default input stream used to read any input. |
private String | defaultTarget
Name of the project's default target. |
private String | description
Description for this project (if any). |
private static final FileUtils | FILE_UTILS
Instance of a utility class to use for file operations. |
private final FilterSetCollection | globalFilters
Wrapper around globalFilterSet. |
private final FilterSet | globalFilterSet
Set of global filters. |
private final HashMap | idReferences
Map of id references - used for indicating broken build files |
private InputHandler | inputHandler
Called to handle any input requests. |
private final ThreadLocal | isLoggingMessage
for each thread, record whether it is currently executing messageLogged |
public static final String | JAVA_1_0
Version constant for Java 1.0 . |
public static final String | JAVA_1_1
Version constant for Java 1.1 . |
public static final String | JAVA_1_2
Version constant for Java 1.2 . |
public static final String | JAVA_1_3
Version constant for Java 1.3 . |
public static final String | JAVA_1_4
Version constant for Java 1.4 . |
private boolean | keepGoingMode
Keep going flag. |
private volatile BuildListener[] | listeners
List of listeners to notify of build events. |
private final Object | listenersLock
lock object used when adding/removing listeners |
public static final int | MSG_DEBUG
Message priority of "debug". |
public static final int | MSG_ERR
Message priority of "error". |
public static final int | MSG_INFO
Message priority of "information". |
public static final int | MSG_VERBOSE
Message priority of "verbose". |
public static final int | MSG_WARN
Message priority of "warning". |
private String | name
Name of this project. |
private final Hashtable | references
Map of references within the project (paths etc) (String to Object). |
private final Object | referencesLock
lock object used when adding/removing references |
private final Hashtable | targets
Map from target names to targets (String to Target). |
private final Map | threadGroupTasks
Records the latest task to be executed on a thread group. |
private final Map | threadTasks
Records the latest task to be executed on a thread. |
public static final String | TOKEN_END
Default filter end token. |
public static final String | TOKEN_START
Default filter start token. |
private static final String | VISITED
Constant for the "visited" state, used when traversing a DFS of target dependencies. |
private static final String | VISITING
Constant for the "visiting" state, used when traversing a DFS of target dependencies. |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
public void | addBuildListener(final BuildListener
The listener to add to the list.
Must not be listener)null .Add a build listener to the list. |
public void | addDataTypeDefinition(final String
The name of the datatype.
Must not be typeName, final Class<?> null .The full name of the class implementing the datatype.
Must not be typeClass)null .Add a new datatype definition. |
public void | |
public void | addIdReference(final String
the id to set. id, final Object the value to set it to (Unknown element in this case. value)Add an id reference. |
public void | addOrReplaceTarget(final Target
The target to be added or replaced in the project.
Must not be target)null .Add a target to the project, or replaces one with the same name. |
public void | addOrReplaceTarget(final String
The name to use for the target.
Must not be targetName, final Target null .The target to be added or replaced in the project.
Must not be target)null .Add a target to the project, or replaces one with the same name. |
public void | addReference(final String
The name of the reference. Must not be referenceName, final Object null .The value of the reference. value)Add a reference to the project. |
public void | |
public void | |
public void | addTaskDefinition(final String
The name of the task to add.
Must not be taskName, final Class<?> null .The full name of the class implementing the task.
Must not be taskClass)null .Add a new task definition to the project. |
public void | checkTaskClass(final Class<?>
The class to be checked.
Must not be taskClass)null .Check whether or not a class is suitable for serving as Ant task. |
public void | |
public void | copyFile(final String
Name of file to copy from.
Must not be sourceFile, final String null .Name of file to copy to.
Must not be destFile, final boolean null .Whether or not token filtering should be used during
the copy. filtering)
Deprecated
since 1.4.x
Convenience method to copy a file from a source to a destination
specifying if token filtering should be used.
|
public void | copyFile(final String
Name of file to copy from.
Must not be sourceFile, final String null .Name of file to copy to.
Must not be destFile, final boolean null .Whether or not token filtering should be used during
the copy. filtering, final boolean Whether or not the destination file should be
overwritten if it already exists. overwrite)
Deprecated
since 1.4.x
Convenience method to copy a file from a source to a
destination specifying if token filtering should be used and if
source files may overwrite newer destination files.
|
public void | copyFile(final String
Name of file to copy from.
Must not be sourceFile, final String null .Name of file to copy to.
Must not be destFile, final boolean null .Whether or not token filtering should be used during
the copy. filtering, final boolean Whether or not the destination file should be
overwritten if it already exists. overwrite, final boolean Whether or not the last modified time of
the resulting file should be set to that
of the source file. preserveLastModified)
Deprecated
since 1.4.x
Convenience method to copy a file from a source to a
destination specifying if token filtering should be used, if
source files may overwrite newer destination files, and if the
last modified time of the resulting file should be set to
that of the source file.
|
public void | |
public void | copyFile(final File
File to copy from.
Must not be sourceFile, final File null .File to copy to.
Must not be destFile, final boolean null .Whether or not token filtering should be used during
the copy. filtering)
Deprecated
since 1.4.x
Convenience method to copy a file from a source to a destination
specifying if token filtering should be used.
|
public void | copyFile(final File
File to copy from.
Must not be sourceFile, final File null .File to copy to.
Must not be destFile, final boolean null .Whether or not token filtering should be used during
the copy. filtering, final boolean Whether or not the destination file should be
overwritten if it already exists. overwrite)
Deprecated
since 1.4.x
Convenience method to copy a file from a source to a
destination specifying if token filtering should be used and if
source files may overwrite newer destination files.
|
public void | copyFile(final File
File to copy from.
Must not be sourceFile, final File null .File to copy to.
Must not be destFile, final boolean null .Whether or not token filtering should be used during
the copy. filtering, final boolean Whether or not the destination file should be
overwritten if it already exists. overwrite, final boolean Whether or not the last modified time of
the resulting file should be set to that
of the source file. preserveLastModified)
Deprecated
since 1.4.x
Convenience method to copy a file from a source to a
destination specifying if token filtering should be used, if
source files may overwrite newer destination files, and if the
last modified time of the resulting file should be set to
that of the source file.
|
public void | copyInheritedProperties(final Project
the project to copy the properties to. Must not be null. other)Copy all user properties that have not been set on the command line or a GUI tool from this instance to the Project instance given as the argument. |
public void | copyUserProperties(final Project
the project to copy the properties to. Must not be null. other)Copy all user properties that have been set on the command line or a GUI tool from this instance to the Project instance given as the argument. |
public AntClassLoader | Returns: an appropriate classloader.the path from which classes are to be loaded. path)Factory method to create a class loader for loading classes from a given path. |
public AntClassLoader | Returns: an appropriate classloader.the parent classloader for the new loader. parent, final Path the path from which classes are to be loaded. path)Factory method to create a class loader for loading classes from a given path. |
public Object | Returns: an instance of the specified data type, ornull if
the data type name is not recognised.The name of the data type to create an instance of.
Must not be typeName)null .Create a new instance of a data type. |
public Project | Returns: a Project instance configured as a subproject of this Project.Create and initialize a subproject. |
public Task | Returns: an instance of the specified task, ornull if
the task name is not recognised.The name of the task to create an instance of.
Must not be taskType)null .Create a new instance of a task, adding it to a list of created tasks for later invalidation. |
public int | Returns: the number of bytes read.the buffer into which data is to be read. buffer, final int the offset into the buffer at which data is stored. offset, final int the amount of data to read. length)Read data from the default input stream. |
public void | demuxFlush(final String
Message to handle. Should not be output, final boolean null .Whether the text represents an error ( isError)true )
or information (false ).Demultiplex flush operations so that each task receives the appropriate messages. |
public int | Returns: the number of bytes read.the buffer into which data is to be read. buffer, final int the offset into the buffer at which data is stored. offset, final int the amount of data to read. length)Demux an input request to the correct task. |
public void | demuxOutput(final String
Message to handle. Should not be output, final boolean null .Whether the text represents an warning ( isWarning)true )
or information (false ).Demultiplex output so that each task receives the appropriate messages. |
public void | executeSortedTargets(final Vector<Target>
the aforementioned sortedTargets)Vector .Execute a |
public void | executeTarget(final String
The name of the target to execute.
Must not be targetName)null .Execute the specified target and any targets it depends on. |
public void | executeTargets(final Vector<String>
A vector of target name strings to execute.
Must not be names)null .Execute the specified sequence of targets, and the targets they depend on. |
public void | fireBuildFinished(final Throwable
an exception indicating a reason for a build
failure. May be exception)null , indicating
a successful build.Send a "build finished" event to the build listeners for this project. |
public void | |
protected void | fireMessageLogged(final Project
The project generating the event.
Should not be project, final String null .The message to send. Should not be message, final int null .The priority of the message. priority)Send a "message logged" project level event to the build listeners for this project. |
protected void | fireMessageLogged(final Project
The project generating the event.
Should not be project, final String null .The message to send. Should not be message, final Throwable null .The exception that caused this message. May be throwable, final int null .The priority of the message. priority)Send a "message logged" project level event to the build listeners for this project. |
protected void | fireMessageLogged(final Target
The target generating the event.
Must not be target, final String null .The message to send. Should not be message, final int null .The priority of the message. priority)Send a "message logged" target level event to the build listeners for this project. |
protected void | fireMessageLogged(final Target
The target generating the event.
Must not be target, final String null .The message to send. Should not be message, final Throwable null .The exception that caused this message. May be throwable, final int null .The priority of the message. priority)Send a "message logged" target level event to the build listeners for this project. |
protected void | fireMessageLogged(final Task
The task generating the event.
Must not be task, final String null .The message to send. Should not be message, final int null .The priority of the message. priority)Send a "message logged" task level event to the build listeners for this project. |
protected void | fireMessageLogged(final Task
The task generating the event.
Must not be task, final String null .The message to send. Should not be message, final Throwable null .The exception that caused this message. May be throwable, final int null .The priority of the message. priority)Send a "message logged" task level event to the build listeners for this project. |
private void | fireMessageLoggedEvent(final BuildEvent
The event to send. This should be built up with the
appropriate task/target/project by the caller, so that
this method can set the message and priority, then send
the event. Must not be event, String null .The message to send. Should not be message, final int null .The priority of the message. priority)Send a "message logged" event to the build listeners for this project. |
public void | fireSubBuildFinished(final Throwable
an exception indicating a reason for a build
failure. May be exception)null , indicating
a successful build.Send a "subbuild finished" event to the build listeners for this project. |
public void | |
protected void | fireTargetFinished(final Target
The target which has finished building.
Must not be target, final Throwable null .an exception indicating a reason for a build
failure. May be exception)null , indicating
a successful build.Send a "target finished" event to the build listeners for this project. |
protected void | fireTargetStarted(final Target
The target which is starting to build.
Must not be target)null .Send a "target started" event to the build listeners for this project. |
protected void | fireTaskFinished(final Task
The task which has finished executing.
Must not be task, final Throwable null .an exception indicating a reason for a build
failure. May be exception)null , indicating
a successful build.Send a "task finished" event to the build listeners for this project. |
protected void | fireTaskStarted(final Task
The target which is starting to execute.
Must not be task)null .Send a "task started" event to the build listeners for this project. |
public File | Returns: the project base directory, ornull if the
base directory has not been successfully set to a valid value.Return the base directory of the project as a file object. |
public Vector | Returns: a list of build listeners for the projectReturn a copy of the list of build listeners for the project. |
public Map | Returns: a map of from datatype name to implementing class (String to Class).Return the current datatype definition map. |
public Map | Returns: a map of the references in the project (String to Object).Return a map of the references in the project (String to Object). |
public Map | |
public Map | Returns: a map of from task name to implementing class (String to Class).Return the current task definition map. |
public ClassLoader | Returns: the core classloader to use for this project.Return the core classloader to use for this project. |
public Hashtable | Returns: a map of from datatype name to implementing class (String to Class).Return the current datatype definition hashtable. |
public InputStream | Returns: the InputStream instance in use by this Project instance to read input.Get this project's input stream. |
public String | Returns: name of the default target ornull if no default has been set.Return the name of the default target of the project. |
public String | Returns: the project description, ornull if it hasn't
been set.Return the project description, if one has been set. |
public String | Returns: a description of the element type.The element to describe.
Must not be element)null .Return a description of the type of the given element, with special handling for instances of tasks and data types. |
public Executor | |
public Hashtable | Returns: a hashtable of global filters, mapping tokens to values (String to String).
Deprecated
since 1.4.x
Use getGlobalFilterSet().getFilterHash().
Return a hashtable of global filters, mapping tokens to values.
|
public FilterSet | |
public Hashtable | Returns: a hashtable containing just the inherited properties.Return a copy of the inherited property hashtable. |
public InputHandler | Returns: the InputHandler instance currently in place for the project instance.Retrieve the current input handler. |
public static String | Returns: the version of Java as a String, e.g. "1.1" .
Deprecated
since 1.5.x.
Use org.apache.tools.ant.util.JavaEnvUtils instead.
Return the version of Java this class is running under.
|
public String | Returns: the project name, ornull if it hasn't been set.Return the project name, if one has been set. |
public static Project | Returns: Project instance, if any.the object to query. o)Get the Project instance associated with the specified object. |
public Hashtable | Returns: a hashtable containing all properties (including user properties) known to the project directly, does not contain local properties.Return a copy of the properties table. |
public String | Returns: the property value, ornull for no match
or if a null name is provided.The name of the property.
May be propertyName)null , in which case
the return value is also null .Return the value of a property, if it is set. |
public Set | Returns: the names of all known properties including local user and local properties.Returns the names of all known properties. |
public < desired type T> T | Returns: the reference with the specified ID, ornull if
there is no such reference in the project, with type inference.The key for the desired reference.
Must not be key)null .Look up a reference by its key (ID). |
public Hashtable | Returns: a map of the references in the project (String to Object).Return a map of the references in the project (String to Object). |
public Resource | Returns: the file resource.the name of the file to resolve. name)Implements org. |
public Hashtable | |
public Hashtable | Returns: a map of from task name to implementing class (String to Class).Return the current task definition hashtable. |
public Task | Returns: the task which is currently registered for the given thread or null if no task is registered.the thread for which the task is required. thread)Get the current task associated with a thread, if any. |
public Hashtable | Returns: a hashtable containing just the user properties.Return a copy of the user property hashtable. |
public String | Returns: the property value, ornull for no match
or if a null name is provided.The name of the property.
May be propertyName)null , in which case
the return value is also null .Return the value of a user property, if it is set. |
public boolean | |
public void | inheritIDReferences(final Project
the parent project of this project. parent)Inherit the id references. |
public void | |
public void | |
public void | |
public boolean | |
public void | |
public void | |
public void | |
public void | |
public void | log(final Task
The task to use in the log. Must not be task, final String null .The text to log. Should not be message, final Throwable null .The exception causing this log, may be throwable, final int null .The log priority level to use. msgLevel)Write a task level message to the log with the given log level. |
public void | |
public void | log(final Target
The target to use in the log.
Must not be target, final String null .The text to log. Should not be message, final Throwable null .The exception causing this log, may be throwable, final int null .The log priority level to use. msgLevel)Write a target level message to the log with the given log level. |
private static BuildException | Returns: a BuildException detailing the specified circular dependency.The dependency to stop at. Must not be end, final Stack<String> null .A stack of dependencies. Must not be stk)null .Build an appropriate exception detailing a specified circular dependency. |
public void | registerThreadTask(final Thread
the thread on which the task is registered. thread, final Task the task to be registered. task)Register a task as the current task for a thread. |
public void | removeBuildListener(final BuildListener
The listener to remove from the list.
Should not be listener)null .Remove a build listener from the list. |
public String | Returns: the given string with embedded property names replaced by values, ornull if the given string is
null .The string to be scanned for property references.
May be value)null .Replace ${} style constructions in the given value with the string value of the corresponding data types. |
public File | Returns: the resolved File.The name of the file to resolve.
Must not be fileName, final File null .The directory respective to which relative file names
are resolved. May be rootDir)null , in which case
the current directory is used.
Deprecated
since 1.4.x
Return the canonical form of a filename.
|
public File | Returns: the resolved File.The name of the file to resolve.
Must not be fileName)null .Return the canonical form of a filename. |
private void | |
public void | setBasedir(final String
The project base directory.
Must not be baseD)null .Set the base directory for the project, checking that the given filename exists and is a directory. |
public void | setBaseDir(File
The project base directory.
Must not be baseDir)null .Set the base directory for the project, checking that the given file exists and is a directory. |
public void | setCoreLoader(final ClassLoader
The classloader to use for the project.
May be coreLoader)null .Set the core classloader for the project. |
public void | setDefault(final String
The name of the default target for this project.
May be defaultTarget)null , indicating that there is
no default target.Set the default target of the project. |
public void | setDefaultInputStream(final InputStream
the default input stream to use when input
is requested. defaultInputStream)Set the default System input stream. |
public void | setDefaultTarget(final String
The name of the default target for this project.
May be defaultTarget)null , indicating that there is
no default target.
Deprecated
since 1.5.x.
Use setDefault.
Set the default target of the project.
|
public void | setDescription(final String
The description of the project.
May be description)null .Set the project description. |
public void | |
public void | setFileLastModified(final File
The file to set the last modified time on.
Must not be file, final long null .the required modification time. time)
Deprecated
since 1.4.x
Call File.setLastModified(long time) on Java above 1.1, and logs
a warning on Java 1.1.
|
public void | setInheritedProperty(final String
The name of property to set.
Must not be name, final String null .The new value of the property.
Must not be value)null .Set a user property, which cannot be overwritten by set/unset property calls. |
public void | setInputHandler(final InputHandler
the InputHandler instance to use for gathering input. handler)Set the input handler. |
public void | |
public void | |
public void | |
public void | setNewProperty(final String
The name of property to set.
Must not be name, final String null .The new value of the property.
Must not be value)null .Set a property if no value currently exists. |
public final void | setProjectReference(final Object
the object to invoke setProject(this) on. obj)Set a reference to this Project on the parameterized object. |
public void | setProperty(final String
The name of property to set.
Must not be name, final String null .The new value of the property.
Must not be value)null .Set a property. |
private void | setPropertyInternal(final String
The name of the property.
Must not be name, final String null .The property value. Must not be value)null .Set a property unless it is already defined as a user property (in which case the method returns silently). |
public void | setSystemProperties()
Add all system properties which aren't already defined as user properties to the project properties. |
public void | setUserProperty(final String
The name of property to set.
Must not be name, final String null .The new value of the property.
Must not be value)null .Set a user property, which cannot be overwritten by set/unset property calls. |
public static boolean | |
public final Vector | Returns: a Vector of ALL Target objects in sorted order.The name of the root target. The sort is created in such
a way that the sequence of Targets up to the root
target is the minimum possible such sequence.
Must not be root, final Hashtable<String, Target> null .A Hashtable mapping names to Targets.
Must not be targetTable)null .Topologically sort a set of targets. |
public final Vector | Returns: a Vector of Target objects in sorted order.The name of the root target. The sort is created in such
a way that the sequence of Targets up to the root
target is the minimum possible such sequence.
Must not be root, final Hashtable<String, Target> null .A Hashtable mapping names to Targets.
Must not be targetTable, final boolean null .boolean indicating whether to return all
targets, or the execution sequence only.Topologically sort a set of targets. |
public final Vector | Returns: a Vector of Target objects in sorted order.String[] containing the names of the root targets.
The sort is created in such a way that the ordered sequence of
Targets is the minimum possible such sequence to the specified
root targets.
Must not be null .A map of names to targets (String to Target).
Must not be targetTable, final boolean null .boolean indicating whether to return all
targets, or the execution sequence only.Topologically sort a set of targets. |
public static String | Returns: the native version of the specified path or an empty string if the path isnull or empty.The path to be translated.
May be toProcess)null .
Deprecated
since 1.7
Use FileUtils.translatePath instead.
Translate a path into its native (platform specific) format.
|
private void | tsort(final String
The current target to inspect.
Must not be root, final Hashtable<String, Target> null .A mapping from names to targets (String to Target).
Must not be targetTable, final Hashtable<String, String> null .A mapping from target names to states (String to String).
The states in question are "VISITING" and
"VISITED". Must not be state, final Stack<String> null .A stack of targets which are currently being visited.
Must not be visiting, final Vector<Target> null .The list to add target names to. This will end up
containing the complete list of dependencies in
dependency order.
Must not be ret)null .Perform a single step in a recursive depth-first-search traversal of the target dependency tree. |