Methods Summary |
---|
public synchronized void | addBuildListener(BuildListener listener)Add a build listener to the list. This listener will
be notified of build events for this project.
// If the listeners already has this listener, do nothing
if (listeners.contains(listener)) {
return;
}
// create a new Vector to avoid ConcurrentModificationExc when
// the listeners get added/removed while we are in fire
Vector newListeners = getBuildListeners();
newListeners.addElement(listener);
listeners = newListeners;
|
public void | addDataTypeDefinition(java.lang.String typeName, java.lang.Class typeClass)Add a new datatype definition.
Attempting to override an existing definition with an
equivalent one (i.e. with the same classname) results in
a verbose log message. Attempting to override an existing definition
with a different one results in a warning log message, but the
definition is changed.
ComponentHelper.getComponentHelper(this).addDataTypeDefinition(typeName,
typeClass);
|
public void | addFilter(java.lang.String token, java.lang.String value)Add a filter to the set of global filters.
if (token == null) {
return;
}
globalFilterSet.addFilter(new FilterSet.Filter(token, value));
|
public void | addIdReference(java.lang.String id, java.lang.Object value)Add an id reference.
Used for broken build files.
idReferences.put(id, value);
|
public void | addOrReplaceTarget(Target target)Add a target to the project, or replaces one with the same
name.
addOrReplaceTarget(target.getName(), target);
|
public void | addOrReplaceTarget(java.lang.String targetName, Target target)Add a target to the project, or replaces one with the same
name.
String msg = " +Target: " + targetName;
log(msg, MSG_DEBUG);
target.setProject(this);
targets.put(targetName, target);
|
public void | addReference(java.lang.String referenceName, java.lang.Object value)Add a reference to the project.
synchronized (references) {
Object old = ((AntRefTable) references).getReal(referenceName);
if (old == value) {
// no warning, this is not changing anything
return;
}
if (old != null && !(old instanceof UnknownElement)) {
log("Overriding previous definition of reference to " + referenceName,
MSG_VERBOSE);
}
log("Adding reference: " + referenceName, MSG_DEBUG);
references.put(referenceName, value);
}
|
public void | addTarget(Target target)Add a new target to the project.
addTarget(target.getName(), target);
|
public void | addTarget(java.lang.String targetName, Target target)Add a new target to the project.
if (targets.get(targetName) != null) {
throw new BuildException("Duplicate target: `" + targetName + "'");
}
addOrReplaceTarget(targetName, target);
|
public void | addTaskDefinition(java.lang.String taskName, java.lang.Class taskClass)Add a new task definition to the project.
Attempting to override an existing definition with an
equivalent one (i.e. with the same classname) results in
a verbose log message. Attempting to override an existing definition
with a different one results in a warning log message and
invalidates any tasks which have already been created with the
old definition.
ComponentHelper.getComponentHelper(this).addTaskDefinition(taskName,
taskClass);
|
public void | checkTaskClass(java.lang.Class taskClass)Check whether or not a class is suitable for serving as Ant task.
Ant task implementation classes must be public, concrete, and have
a no-arg constructor.
ComponentHelper.getComponentHelper(this).checkTaskClass(taskClass);
if (!Modifier.isPublic(taskClass.getModifiers())) {
final String message = taskClass + " is not public";
log(message, Project.MSG_ERR);
throw new BuildException(message);
}
if (Modifier.isAbstract(taskClass.getModifiers())) {
final String message = taskClass + " is abstract";
log(message, Project.MSG_ERR);
throw new BuildException(message);
}
try {
taskClass.getConstructor((Class[]) null);
// don't have to check for public, since
// getConstructor finds public constructors only.
} catch (NoSuchMethodException e) {
final String message = "No public no-arg constructor in "
+ taskClass;
log(message, Project.MSG_ERR);
throw new BuildException(message);
} catch (LinkageError e) {
String message = "Could not load " + taskClass + ": " + e;
log(message, Project.MSG_ERR);
throw new BuildException(message, e);
}
if (!Task.class.isAssignableFrom(taskClass)) {
TaskAdapter.checkTaskClass(taskClass, this);
}
|
public void | copyFile(java.lang.String sourceFile, java.lang.String destFile)Convenience method to copy a file from a source to a destination.
No filtering is performed.
FILE_UTILS.copyFile(sourceFile, destFile);
|
public void | copyFile(java.lang.String sourceFile, java.lang.String destFile, boolean filtering)Convenience method to copy a file from a source to a destination
specifying if token filtering should be used.
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null);
|
public void | copyFile(java.lang.String sourceFile, java.lang.String destFile, boolean filtering, boolean overwrite)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.
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null, overwrite);
|
public void | copyFile(java.lang.String sourceFile, java.lang.String destFile, boolean filtering, boolean overwrite, boolean preserveLastModified)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.
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null, overwrite, preserveLastModified);
|
public void | copyFile(java.io.File sourceFile, java.io.File destFile)Convenience method to copy a file from a source to a destination.
No filtering is performed.
FILE_UTILS.copyFile(sourceFile, destFile);
|
public void | copyFile(java.io.File sourceFile, java.io.File destFile, boolean filtering)Convenience method to copy a file from a source to a destination
specifying if token filtering should be used.
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null);
|
public void | copyFile(java.io.File sourceFile, java.io.File destFile, boolean filtering, boolean overwrite)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.
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null, overwrite);
|
public void | copyFile(java.io.File sourceFile, java.io.File destFile, boolean filtering, boolean overwrite, boolean preserveLastModified)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.
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null, overwrite, preserveLastModified);
|
public void | copyInheritedProperties(org.apache.tools.ant.Project 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.
To copy all "user" properties, you will also have to call
{@link #copyUserProperties copyUserProperties}.
PropertyHelper ph = PropertyHelper.getPropertyHelper(this);
ph.copyInheritedProperties(other);
|
public void | copyUserProperties(org.apache.tools.ant.Project 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.
To copy all "user" properties, you will also have to call
{@link #copyInheritedProperties copyInheritedProperties}.
PropertyHelper ph = PropertyHelper.getPropertyHelper(this);
ph.copyUserProperties(other);
|
public AntClassLoader | createClassLoader(org.apache.tools.ant.types.Path path)Factory method to create a class loader for loading classes from
a given path.
return new AntClassLoader(
getClass().getClassLoader(), this, path);
|
public AntClassLoader | createClassLoader(java.lang.ClassLoader parent, org.apache.tools.ant.types.Path path)Factory method to create a class loader for loading classes from
a given path.
return new AntClassLoader(parent, this, path);
|
public java.lang.Object | createDataType(java.lang.String typeName)Create a new instance of a data type.
return ComponentHelper.getComponentHelper(this).createDataType(typeName);
|
public org.apache.tools.ant.Project | createSubProject()Create and initialize a subproject. By default the subproject will be of
the same type as its parent. If a no-arg constructor is unavailable, the
Project class will be used.
Project subProject = null;
try {
subProject = (Project) (getClass().newInstance());
} catch (Exception e) {
subProject = new Project();
}
initSubProject(subProject);
return subProject;
|
public Task | createTask(java.lang.String taskType)Create a new instance of a task, adding it to a list of
created tasks for later invalidation. This causes all tasks
to be remembered until the containing project is removed
return ComponentHelper.getComponentHelper(this).createTask(taskType);
|
public int | defaultInput(byte[] buffer, int offset, int length)Read data from the default input stream. If no default has been
specified, System.in is used.
if (defaultInputStream != null) {
System.out.flush();
return defaultInputStream.read(buffer, offset, length);
} else {
throw new EOFException("No input provided for project");
}
|
public void | demuxFlush(java.lang.String output, boolean isError)Demultiplex flush operations so that each task receives the appropriate
messages. If the current thread is not currently executing a task,
the message is logged directly.
Task task = getThreadTask(Thread.currentThread());
if (task == null) {
fireMessageLogged(this, output, isError ? MSG_ERR : MSG_INFO);
} else {
if (isError) {
task.handleErrorFlush(output);
} else {
task.handleFlush(output);
}
}
|
public int | demuxInput(byte[] buffer, int offset, int length)Demux an input request to the correct task.
Task task = getThreadTask(Thread.currentThread());
if (task == null) {
return defaultInput(buffer, offset, length);
} else {
return task.handleInput(buffer, offset, length);
}
|
public void | demuxOutput(java.lang.String output, boolean isWarning)Demultiplex output so that each task receives the appropriate
messages. If the current thread is not currently executing a task,
the message is logged directly.
Task task = getThreadTask(Thread.currentThread());
if (task == null) {
log(output, isWarning ? MSG_WARN : MSG_INFO);
} else {
if (isWarning) {
task.handleErrorOutput(output);
} else {
task.handleOutput(output);
}
}
|
public void | executeSortedTargets(java.util.Vector sortedTargets)Execute a Vector of sorted targets.
Set succeededTargets = new HashSet();
BuildException buildException = null; // first build exception
for (Enumeration iter = sortedTargets.elements();
iter.hasMoreElements();) {
Target curtarget = (Target) iter.nextElement();
boolean canExecute = true;
for (Enumeration depIter = curtarget.getDependencies();
depIter.hasMoreElements();) {
String dependencyName = ((String) depIter.nextElement());
if (!succeededTargets.contains(dependencyName)) {
canExecute = false;
log(curtarget,
"Cannot execute '" + curtarget.getName() + "' - '"
+ dependencyName + "' failed or was not executed.",
MSG_ERR);
break;
}
}
if (canExecute) {
Throwable thrownException = null;
try {
curtarget.performTasks();
succeededTargets.add(curtarget.getName());
} catch (RuntimeException ex) {
if (!(keepGoingMode)) {
throw ex; // throw further
}
thrownException = ex;
} catch (Throwable ex) {
if (!(keepGoingMode)) {
throw new BuildException(ex);
}
thrownException = ex;
}
if (thrownException != null) {
if (thrownException instanceof BuildException) {
log(curtarget,
"Target '" + curtarget.getName()
+ "' failed with message '"
+ thrownException.getMessage() + "'.", MSG_ERR);
// only the first build exception is reported
if (buildException == null) {
buildException = (BuildException) thrownException;
}
} else {
log(curtarget,
"Target '" + curtarget.getName()
+ "' failed with message '"
+ thrownException.getMessage() + "'.", MSG_ERR);
thrownException.printStackTrace(System.err);
if (buildException == null) {
buildException =
new BuildException(thrownException);
}
}
}
}
}
if (buildException != null) {
throw buildException;
}
|
public void | executeTarget(java.lang.String targetName)Execute the specified target and any targets it depends on.
// sanity check ourselves, if we've been asked to build nothing
// then we should complain
if (targetName == null) {
String msg = "No target specified";
throw new BuildException(msg);
}
// Sort and run the dependency tree.
// Sorting checks if all the targets (and dependencies)
// exist, and if there is any cycle in the dependency
// graph.
executeSortedTargets(topoSort(targetName, targets, false));
|
public void | executeTargets(java.util.Vector names)Execute the specified sequence of targets, and the targets
they depend on.
getExecutor().executeTargets(this,
(String[]) (names.toArray(new String[names.size()])));
|
public void | fireBuildFinished(java.lang.Throwable exception)Send a "build finished" event to the build listeners
for this project.
BuildEvent event = new BuildEvent(this);
event.setException(exception);
Iterator iter = listeners.iterator();
while (iter.hasNext()) {
BuildListener listener = (BuildListener) iter.next();
listener.buildFinished(event);
}
// Inform IH to clear the cache
IntrospectionHelper.clearCache();
|
public void | fireBuildStarted()Send a "build started" event
to the build listeners for this project.
BuildEvent event = new BuildEvent(this);
Iterator iter = listeners.iterator();
while (iter.hasNext()) {
BuildListener listener = (BuildListener) iter.next();
listener.buildStarted(event);
}
|
protected void | fireMessageLogged(org.apache.tools.ant.Project project, java.lang.String message, int priority)Send a "message logged" project level event
to the build listeners for this project.
fireMessageLogged(project, message, null, priority);
|
protected void | fireMessageLogged(org.apache.tools.ant.Project project, java.lang.String message, java.lang.Throwable throwable, int priority)Send a "message logged" project level event
to the build listeners for this project.
BuildEvent event = new BuildEvent(project);
event.setException(throwable);
fireMessageLoggedEvent(event, message, priority);
|
protected void | fireMessageLogged(Target target, java.lang.String message, int priority)Send a "message logged" target level event
to the build listeners for this project.
fireMessageLogged(target, message, null, priority);
|
protected void | fireMessageLogged(Target target, java.lang.String message, java.lang.Throwable throwable, int priority)Send a "message logged" target level event
to the build listeners for this project.
BuildEvent event = new BuildEvent(target);
event.setException(throwable);
fireMessageLoggedEvent(event, message, priority);
|
protected void | fireMessageLogged(Task task, java.lang.String message, int priority)Send a "message logged" task level event
to the build listeners for this project.
fireMessageLogged(task, message, null, priority);
|
protected void | fireMessageLogged(Task task, java.lang.String message, java.lang.Throwable throwable, int priority)Send a "message logged" task level event
to the build listeners for this project.
BuildEvent event = new BuildEvent(task);
event.setException(throwable);
fireMessageLoggedEvent(event, message, priority);
|
private void | fireMessageLoggedEvent(BuildEvent event, java.lang.String message, int priority)Send a "message logged" event to the build listeners
for this project.
if (message.endsWith(StringUtils.LINE_SEP)) {
int endIndex = message.length() - StringUtils.LINE_SEP.length();
event.setMessage(message.substring(0, endIndex), priority);
} else {
event.setMessage(message, priority);
}
synchronized (this) {
if (loggingMessage) {
/*
* One of the Listeners has attempted to access
* System.err or System.out.
*
* We used to throw an exception in this case, but
* sometimes Listeners can't prevent it(like our own
* Log4jListener which invokes getLogger() which in
* turn wants to write to the console).
*
* @see http://marc.theaimsgroup.com/?t=110538624200006&r=1&w=2
*
* We now (Ant 1.7 and 1.6.3) simply swallow the message.
*/
return;
}
try {
loggingMessage = true;
Iterator iter = listeners.iterator();
while (iter.hasNext()) {
BuildListener listener = (BuildListener) iter.next();
listener.messageLogged(event);
}
} finally {
loggingMessage = false;
}
}
|
public void | fireSubBuildFinished(java.lang.Throwable exception)Send a "subbuild finished" event to the build listeners for
this project.
BuildEvent event = new BuildEvent(this);
event.setException(exception);
Iterator iter = listeners.iterator();
while (iter.hasNext()) {
Object listener = iter.next();
if (listener instanceof SubBuildListener) {
((SubBuildListener) listener).subBuildFinished(event);
}
}
|
public void | fireSubBuildStarted()Send a "subbuild started" event to the build listeners for
this project.
BuildEvent event = new BuildEvent(this);
Iterator iter = listeners.iterator();
while (iter.hasNext()) {
Object listener = iter.next();
if (listener instanceof SubBuildListener) {
((SubBuildListener) listener).subBuildStarted(event);
}
}
|
protected void | fireTargetFinished(Target target, java.lang.Throwable exception)Send a "target finished" event to the build listeners
for this project.
BuildEvent event = new BuildEvent(target);
event.setException(exception);
Iterator iter = listeners.iterator();
while (iter.hasNext()) {
BuildListener listener = (BuildListener) iter.next();
listener.targetFinished(event);
}
|
protected void | fireTargetStarted(Target target)Send a "target started" event to the build listeners
for this project.
BuildEvent event = new BuildEvent(target);
Iterator iter = listeners.iterator();
while (iter.hasNext()) {
BuildListener listener = (BuildListener) iter.next();
listener.targetStarted(event);
}
|
protected void | fireTaskFinished(Task task, java.lang.Throwable exception)Send a "task finished" event to the build listeners for this
project.
registerThreadTask(Thread.currentThread(), null);
System.out.flush();
System.err.flush();
BuildEvent event = new BuildEvent(task);
event.setException(exception);
Iterator iter = listeners.iterator();
while (iter.hasNext()) {
BuildListener listener = (BuildListener) iter.next();
listener.taskFinished(event);
}
|
protected void | fireTaskStarted(Task task)Send a "task started" event to the build listeners
for this project.
// register this as the current task on the current thread.
registerThreadTask(Thread.currentThread(), task);
BuildEvent event = new BuildEvent(task);
Iterator iter = listeners.iterator();
while (iter.hasNext()) {
BuildListener listener = (BuildListener) iter.next();
listener.taskStarted(event);
}
|
public java.io.File | getBaseDir()Return the base directory of the project as a file object.
if (baseDir == null) {
try {
setBasedir(".");
} catch (BuildException ex) {
ex.printStackTrace();
}
}
return baseDir;
|
public java.util.Vector | getBuildListeners()Return a copy of the list of build listeners for the project.
return (Vector) listeners.clone();
|
public java.lang.ClassLoader | getCoreLoader()Return the core classloader to use for this project.
This may be null , indicating that
the parent classloader should be used.
return coreLoader;
|
public java.util.Hashtable | getDataTypeDefinitions()Return the current datatype definition hashtable. The returned
hashtable is "live" and so should not be modified.
return ComponentHelper.getComponentHelper(this).getDataTypeDefinitions();
|
public java.io.InputStream | getDefaultInputStream()Get this project's input stream.
return defaultInputStream;
|
public java.lang.String | getDefaultTarget()Return the name of the default target of the project.
return defaultTarget;
|
public java.lang.String | getDescription()Return the project description, if one has been set.
if (description == null) {
description = Description.getDescription(this);
}
return description;
|
public java.lang.String | getElementName(java.lang.Object element)Return a description of the type of the given element, with
special handling for instances of tasks and data types.
This is useful for logging purposes.
return ComponentHelper.getComponentHelper(this).getElementName(element);
|
public Executor | getExecutor()Get this Project's Executor (setting it if necessary).
Object o = getReference(MagicNames.ANT_EXECUTOR_REFERENCE);
if (o == null) {
String classname = getProperty(MagicNames.ANT_EXECUTOR_CLASSNAME);
if (classname == null) {
classname = DefaultExecutor.class.getName();
}
log("Attempting to create object of type " + classname, MSG_DEBUG);
try {
o = Class.forName(classname, true, coreLoader).newInstance();
} catch (ClassNotFoundException seaEnEfEx) {
//try the current classloader
try {
o = Class.forName(classname).newInstance();
} catch (Exception ex) {
log(ex.toString(), MSG_ERR);
}
} catch (Exception ex) {
log(ex.toString(), MSG_ERR);
}
if (o == null) {
throw new BuildException(
"Unable to obtain a Target Executor instance.");
}
setExecutor((Executor) o);
}
return (Executor) o;
|
public java.util.Hashtable | getFilters()Return a hashtable of global filters, mapping tokens to values.
// we need to build the hashtable dynamically
return globalFilterSet.getFilterHash();
|
public org.apache.tools.ant.types.FilterSet | getGlobalFilterSet()Return the set of global filters.
return globalFilterSet;
|
public org.apache.tools.ant.input.InputHandler | getInputHandler()Retrieve the current input handler.
return inputHandler;
|
public static java.lang.String | getJavaVersion()Return the version of Java this class is running under.
return JavaEnvUtils.getJavaVersion();
|
public java.lang.String | getName()Return the project name, if one has been set.
return name;
|
public java.util.Hashtable | getProperties()Return a copy of the properties table.
PropertyHelper ph = PropertyHelper.getPropertyHelper(this);
return ph.getProperties();
|
public java.lang.String | getProperty(java.lang.String propertyName)Return the value of a property, if it is set.
PropertyHelper ph = PropertyHelper.getPropertyHelper(this);
return (String) ph.getProperty(null, propertyName);
|
public java.lang.Object | getReference(java.lang.String key)Look up a reference by its key (ID).
Object ret = references.get(key);
if (ret != null) {
return ret;
}
// Check for old id behaviour
ret = resolveIdReference(key, this);
if (ret == null && !key.equals(MagicNames.REFID_PROPERTY_HELPER)) {
Vector p = new Vector();
PropertyHelper.getPropertyHelper(this).parsePropertyString(
key, new Vector(), p);
if (p.size() == 1) {
log("Unresolvable reference " + key
+ " might be a misuse of property expansion syntax.",
MSG_WARN);
}
}
return ret;
|
public java.util.Hashtable | getReferences()Return a map of the references in the project (String to Object).
The returned hashtable is "live" and so must not be modified.
return references;
|
public org.apache.tools.ant.types.Resource | getResource(java.lang.String name)Resolve the file relative to the project's basedir and return it as a
FileResource.
return new FileResource(getBaseDir(), name);
|
public java.util.Hashtable | getTargets()Return the hashtable of targets. The returned hashtable
is "live" and so should not be modified.
return targets;
|
public java.util.Hashtable | getTaskDefinitions()Return the current task definition hashtable. The returned hashtable is
"live" and so should not be modified.
return ComponentHelper.getComponentHelper(this).getTaskDefinitions();
|
public Task | getThreadTask(java.lang.Thread thread)Get the current task associated with a thread, if any.
Task task = (Task) threadTasks.get(thread);
if (task == null) {
ThreadGroup group = thread.getThreadGroup();
while (task == null && group != null) {
task = (Task) threadGroupTasks.get(group);
group = group.getParent();
}
}
return task;
|
public java.util.Hashtable | getUserProperties()Return a copy of the user property hashtable.
PropertyHelper ph = PropertyHelper.getPropertyHelper(this);
return ph.getUserProperties();
|
public java.lang.String | getUserProperty(java.lang.String propertyName)Return the value of a user property, if it is set.
PropertyHelper ph = PropertyHelper.getPropertyHelper(this);
return (String) ph.getUserProperty(null, propertyName);
|
public void | inheritIDReferences(org.apache.tools.ant.Project parent)Inherit the id references.
parentIdProject = parent;
|
public void | init()Initialise the project.
This involves setting the default task definitions and loading the
system properties.
initProperties();
ComponentHelper.getComponentHelper(this).initDefaultDefinitions();
|
public void | initProperties()Initializes the properties.
setJavaVersionProperty();
setSystemProperties();
setPropertyInternal(MagicNames.ANT_VERSION, Main.getAntVersion());
setAntLib();
|
public void | initSubProject(org.apache.tools.ant.Project subProject)Initialize a subproject.
ComponentHelper.getComponentHelper(subProject)
.initSubProject(ComponentHelper.getComponentHelper(this));
subProject.setDefaultInputStream(getDefaultInputStream());
subProject.setKeepGoingMode(this.isKeepGoingMode());
subProject.setExecutor(getExecutor().getSubProjectExecutor());
|
public boolean | isKeepGoingMode()Return the keep-going mode. If the keepGoing settor/getter
methods are used in conjunction with the ant.executor.class
property, they will have no effect.
return this.keepGoingMode;
|
public void | log(java.lang.String message)Write a message to the log with the default log level
of MSG_INFO .
log(message, MSG_INFO);
|
public void | log(java.lang.String message, int msgLevel)Write a project level message to the log with the given log level.
log(message, null, msgLevel);
|
public void | log(java.lang.String message, java.lang.Throwable throwable, int msgLevel)Write a project level message to the log with the given log level.
fireMessageLogged(this, message, throwable, msgLevel);
|
public void | log(Task task, java.lang.String message, int msgLevel)Write a task level message to the log with the given log level.
fireMessageLogged(task, message, null, msgLevel);
|
public void | log(Task task, java.lang.String message, java.lang.Throwable throwable, int msgLevel)Write a task level message to the log with the given log level.
fireMessageLogged(task, message, throwable, msgLevel);
|
public void | log(Target target, java.lang.String message, int msgLevel)Write a target level message to the log with the given log level.
log(target, message, null, msgLevel);
|
public void | log(Target target, java.lang.String message, java.lang.Throwable throwable, int msgLevel)Write a target level message to the log with the given log level.
fireMessageLogged(target, message, throwable, msgLevel);
|
private static BuildException | makeCircularException(java.lang.String end, java.util.Stack stk)Build an appropriate exception detailing a specified circular
dependency.
StringBuffer sb = new StringBuffer("Circular dependency: ");
sb.append(end);
String c;
do {
c = (String) stk.pop();
sb.append(" <- ");
sb.append(c);
} while (!c.equals(end));
return new BuildException(new String(sb));
|
public synchronized void | registerThreadTask(java.lang.Thread thread, Task task)Register a task as the current task for a thread.
If the task is null, the thread's entry is removed.
if (task != null) {
threadTasks.put(thread, task);
threadGroupTasks.put(thread.getThreadGroup(), task);
} else {
threadTasks.remove(thread);
threadGroupTasks.remove(thread.getThreadGroup());
}
|
public synchronized void | removeBuildListener(BuildListener listener)Remove a build listener from the list. This listener
will no longer be notified of build events for this project.
// create a new Vector to avoid ConcurrentModificationExc when
// the listeners get added/removed while we are in fire
Vector newListeners = getBuildListeners();
newListeners.removeElement(listener);
listeners = newListeners;
|
public java.lang.String | replaceProperties(java.lang.String value)Replace ${} style constructions in the given value with the
string value of the corresponding data types.
PropertyHelper ph = PropertyHelper.getPropertyHelper(this);
return ph.replaceProperties(null, value, null);
|
public java.io.File | resolveFile(java.lang.String fileName, java.io.File rootDir)Return the canonical form of a filename.
If the specified file name is relative it is resolved
with respect to the given root directory.
return FILE_UTILS.resolveFile(rootDir, fileName);
|
public java.io.File | resolveFile(java.lang.String fileName)Return the canonical form of a filename.
If the specified file name is relative it is resolved
with respect to the project's base directory.
return FILE_UTILS.resolveFile(baseDir, fileName);
|
private java.lang.Object | resolveIdReference(java.lang.String key, org.apache.tools.ant.Project callerProject)Attempt to resolve an Unknown Reference using the
parsed id's - for BC.
UnknownElement origUE = (UnknownElement) idReferences.get(key);
if (origUE == null) {
return parentIdProject == null
? null
: parentIdProject.resolveIdReference(key, callerProject);
}
callerProject.log(
"Warning: Reference " + key + " has not been set at runtime,"
+ " but was found during" + LINE_SEP
+ "build file parsing, attempting to resolve."
+ " Future versions of Ant may support" + LINE_SEP
+ " referencing ids defined in non-executed targets.", MSG_WARN);
UnknownElement copyUE = origUE.copy(callerProject);
copyUE.maybeConfigure();
return copyUE.getRealThing();
|
private void | setAntLib()
File antlib = org.apache.tools.ant.launch.Locator.getClassSource(
Project.class);
if (antlib != null) {
setPropertyInternal(MagicNames.ANT_LIB, antlib.getAbsolutePath());
}
|
public void | setBaseDir(java.io.File baseDir)Set the base directory for the project, checking that
the given file exists and is a directory.
baseDir = FILE_UTILS.normalize(baseDir.getAbsolutePath());
if (!baseDir.exists()) {
throw new BuildException("Basedir " + baseDir.getAbsolutePath()
+ " does not exist");
}
if (!baseDir.isDirectory()) {
throw new BuildException("Basedir " + baseDir.getAbsolutePath()
+ " is not a directory");
}
this.baseDir = baseDir;
setPropertyInternal(MagicNames.PROJECT_BASEDIR, this.baseDir.getPath());
String msg = "Project base dir set to: " + this.baseDir;
log(msg, MSG_VERBOSE);
|
public void | setBasedir(java.lang.String baseD)Set the base directory for the project, checking that
the given filename exists and is a directory.
setBaseDir(new File(baseD));
|
public void | setCoreLoader(java.lang.ClassLoader coreLoader)Set the core classloader for the project. If a null
classloader is specified, the parent classloader should be used.
this.coreLoader = coreLoader;
|
public void | setDefault(java.lang.String defaultTarget)Set the default target of the project.
this.defaultTarget = defaultTarget;
|
public void | setDefaultInputStream(java.io.InputStream defaultInputStream)Set the default System input stream. Normally this stream is set to
System.in. This inputStream is used when no task input redirection is
being performed.
this.defaultInputStream = defaultInputStream;
|
public void | setDefaultTarget(java.lang.String defaultTarget)Set the default target of the project.
this.defaultTarget = defaultTarget;
|
public void | setDescription(java.lang.String description)Set the project description.
this.description = description;
|
public void | setExecutor(Executor e)Set the Executor instance for this Project.
addReference(MagicNames.ANT_EXECUTOR_REFERENCE, e);
|
public void | setFileLastModified(java.io.File file, long time)Call File.setLastModified(long time) on Java above 1.1, and logs
a warning on Java 1.1.
FILE_UTILS.setFileLastModified(file, time);
log("Setting modification time for " + file, MSG_VERBOSE);
|
public void | setInheritedProperty(java.lang.String name, java.lang.String value)Set a user property, which cannot be overwritten by set/unset
property calls. Any previous value is overwritten. Also marks
these properties as properties that have not come from the
command line.
PropertyHelper ph = PropertyHelper.getPropertyHelper(this);
ph.setInheritedProperty(null, name, value);
|
public void | setInputHandler(org.apache.tools.ant.input.InputHandler handler)Set the input handler.
inputHandler = handler;
|
public void | setJavaVersionProperty()Set the ant.java.version property and tests for
unsupported JVM versions. If the version is supported,
verbose log messages are generated to record the Java version
and operating system name.
String javaVersion = JavaEnvUtils.getJavaVersion();
setPropertyInternal(MagicNames.ANT_JAVA_VERSION, javaVersion);
// sanity check
if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_0)
|| JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) {
throw new BuildException("Ant cannot work on Java 1.0 / 1.1");
}
log("Detected Java version: " + javaVersion + " in: "
+ System.getProperty("java.home"), MSG_VERBOSE);
log("Detected OS: " + System.getProperty("os.name"), MSG_VERBOSE);
|
public void | setKeepGoingMode(boolean keepGoingMode)Set "keep-going" mode. In this mode Ant will try to execute
as many targets as possible. All targets that do not depend
on failed target(s) will be executed. If the keepGoing settor/getter
methods are used in conjunction with the ant.executor.class
property, they will have no effect.
this.keepGoingMode = keepGoingMode;
|
public void | setName(java.lang.String name)Set the name of the project, also setting the user
property ant.project.name .
setUserProperty("ant.project.name", name);
this.name = name;
|
public void | setNewProperty(java.lang.String name, java.lang.String value)Set a property if no value currently exists. If the property
exists already, a message is logged and the method returns with
no other effect.
PropertyHelper.getPropertyHelper(this).setNewProperty(null, name,
value);
|
public final void | setProjectReference(java.lang.Object obj)Set a reference to this Project on the parameterized object.
Need to set the project before other set/add elements
are called.
if (obj instanceof ProjectComponent) {
((ProjectComponent) obj).setProject(this);
return;
}
try {
Method method =
obj.getClass().getMethod(
"setProject", new Class[] {Project.class});
if (method != null) {
method.invoke(obj, new Object[] {this});
}
} catch (Throwable e) {
// ignore this if the object does not have
// a set project method or the method
// is private/protected.
}
|
public void | setProperty(java.lang.String name, java.lang.String value)Set a property. Any existing property of the same name
is overwritten, unless it is a user property.
PropertyHelper.getPropertyHelper(this).
setProperty(null, name, value, true);
|
private void | setPropertyInternal(java.lang.String name, java.lang.String value)Set a property unless it is already defined as a user property
(in which case the method returns silently).
PropertyHelper ph = PropertyHelper.getPropertyHelper(this);
ph.setProperty(null, name, value, false);
|
public void | setSystemProperties()Add all system properties which aren't already defined as
user properties to the project properties.
Properties systemP = System.getProperties();
Enumeration e = systemP.propertyNames();
while (e.hasMoreElements()) {
String propertyName = (String) e.nextElement();
String value = systemP.getProperty(propertyName);
this.setPropertyInternal(propertyName, value);
}
|
public void | setUserProperty(java.lang.String name, java.lang.String value)Set a user property, which cannot be overwritten by
set/unset property calls. Any previous value is overwritten.
PropertyHelper.getPropertyHelper(this).setUserProperty(null, name,
value);
|
public static boolean | toBoolean(java.lang.String s)Return the boolean equivalent of a string, which is considered
true if either "on" , "true" ,
or "yes" is found, ignoring case.
return ("on".equalsIgnoreCase(s)
|| "true".equalsIgnoreCase(s)
|| "yes".equalsIgnoreCase(s));
|
public final java.util.Vector | topoSort(java.lang.String root, java.util.Hashtable targetTable)Topologically sort a set of targets. Equivalent to calling
topoSort(new String[] {root}, targets, true) .
return topoSort(new String[] {root}, targetTable, true);
|
public final java.util.Vector | topoSort(java.lang.String root, java.util.Hashtable targetTable, boolean returnAll)Topologically sort a set of targets. Equivalent to calling
topoSort(new String[] {root}, targets, returnAll) .
return topoSort(new String[] {root}, targetTable, returnAll);
|
public final java.util.Vector | topoSort(java.lang.String[] root, java.util.Hashtable targetTable, boolean returnAll)Topologically sort a set of targets.
Vector ret = new Vector();
Hashtable state = new Hashtable();
Stack visiting = new Stack();
// We first run a DFS based sort using each root as a starting node.
// This creates the minimum sequence of Targets to the root node(s).
// We then do a sort on any remaining unVISITED targets.
// This is unnecessary for doing our build, but it catches
// circular dependencies or missing Targets on the entire
// dependency tree, not just on the Targets that depend on the
// build Target.
for (int i = 0; i < root.length; i++) {
String st = (String) (state.get(root[i]));
if (st == null) {
tsort(root[i], targetTable, state, visiting, ret);
} else if (st == VISITING) {
throw new RuntimeException("Unexpected node in visiting state: "
+ root[i]);
}
}
StringBuffer buf = new StringBuffer("Build sequence for target(s)");
for (int j = 0; j < root.length; j++) {
buf.append((j == 0) ? " `" : ", `").append(root[j]).append('\'");
}
buf.append(" is " + ret);
log(buf.toString(), MSG_VERBOSE);
Vector complete = (returnAll) ? ret : new Vector(ret);
for (Enumeration en = targetTable.keys(); en.hasMoreElements();) {
String curTarget = (String) en.nextElement();
String st = (String) state.get(curTarget);
if (st == null) {
tsort(curTarget, targetTable, state, visiting, complete);
} else if (st == VISITING) {
throw new RuntimeException("Unexpected node in visiting state: "
+ curTarget);
}
}
log("Complete build sequence is " + complete, MSG_VERBOSE);
return ret;
|
public static java.lang.String | translatePath(java.lang.String toProcess)Translate a path into its native (platform specific) format.
This method uses PathTokenizer to separate the input path
into its components. This handles DOS style paths in a relatively
sensible way. The file separators are then converted to their platform
specific versions.
return FileUtils.translatePath(toProcess);
|
private void | tsort(java.lang.String root, java.util.Hashtable targetTable, java.util.Hashtable state, java.util.Stack visiting, java.util.Vector ret)Perform a single step in a recursive depth-first-search traversal of
the target dependency tree.
The current target is first set to the "visiting" state, and
pushed onto the "visiting" stack.
An exception is then thrown if any child of the current node is in the
visiting state, as that implies a circular dependency. The exception
contains details of the cycle, using elements of the "visiting"
stack.
If any child has not already been "visited", this method is
called recursively on it.
The current target is then added to the ordered list of targets. Note
that this is performed after the children have been visited in order
to get the correct order. The current target is set to the
"visited" state.
By the time this method returns, the ordered list contains the sequence
of targets up to and including the current target.
state.put(root, VISITING);
visiting.push(root);
Target target = (Target) targetTable.get(root);
// Make sure we exist
if (target == null) {
StringBuffer sb = new StringBuffer("Target \"");
sb.append(root);
sb.append("\" does not exist in the project \"");
sb.append(name);
sb.append("\". ");
visiting.pop();
if (!visiting.empty()) {
String parent = (String) visiting.peek();
sb.append("It is used from target \"");
sb.append(parent);
sb.append("\".");
}
throw new BuildException(new String(sb));
}
for (Enumeration en = target.getDependencies(); en.hasMoreElements();) {
String cur = (String) en.nextElement();
String m = (String) state.get(cur);
if (m == null) {
// Not been visited
tsort(cur, targetTable, state, visiting, ret);
} else if (m == VISITING) {
// Currently visiting this node, so have a cycle
throw makeCircularException(cur, visiting);
}
}
String p = (String) visiting.pop();
if (root != p) {
throw new RuntimeException("Unexpected internal error: expected to "
+ "pop " + root + " but got " + p);
}
state.put(root, VISITED);
ret.addElement(target);
|