| Method from org.apache.tools.ant.Project Detail: |
public void addBuildListener(BuildListener listener) {
synchronized (listenersLock) {
// If the listeners already has this listener, do nothing
for (int i = 0; i < listeners.length; i++) {
if (listeners[i] == listener) {
return;
}
}
// copy on write semantics
BuildListener[] newListeners =
new BuildListener[listeners.length + 1];
System.arraycopy(listeners, 0, newListeners, 0, listeners.length);
newListeners[listeners.length] = listener;
listeners = newListeners;
}
}
Add a build listener to the list. This listener will
be notified of build events for this project. |
public void addDataTypeDefinition(String typeName,
Class typeClass) {
ComponentHelper.getComponentHelper(this).addDataTypeDefinition(typeName,
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. |
public void addFilter(String token,
String value) {
if (token == null) {
return;
}
globalFilterSet.addFilter(new FilterSet.Filter(token, value));
} Deprecated! since - 1.4.x.
Use getGlobalFilterSet().addFilter(token,value)
Add a filter to the set of global filters. |
public void addIdReference(String id,
Object value) {
idReferences.put(id, value);
}
Add an id reference.
Used for broken build files. |
public void addOrReplaceTarget(Target target) {
addOrReplaceTarget(target.getName(), target);
}
Add a target to the project, or replaces one with the same
name. |
public void addOrReplaceTarget(String targetName,
Target target) {
String msg = " +Target: " + targetName;
log(msg, MSG_DEBUG);
target.setProject(this);
targets.put(targetName, target);
}
Add a target to the project, or replaces one with the same
name. |
public void addReference(String referenceName,
Object value) {
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);
}
Add a reference to the project. |
public void addTarget(Target target) throws BuildException {
addTarget(target.getName(), target);
}
Add a new target to the project. |
public void addTarget(String targetName,
Target target) throws BuildException {
if (targets.get(targetName) != null) {
throw new BuildException("Duplicate target: `" + targetName + "'");
}
addOrReplaceTarget(targetName, target);
}
Add a new target to the project. |
public void addTaskDefinition(String taskName,
Class taskClass) throws BuildException {
ComponentHelper.getComponentHelper(this).addTaskDefinition(taskName,
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. |
public void checkTaskClass(Class taskClass) throws BuildException {
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);
}
}
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. |
public void copyFile(String sourceFile,
String destFile) throws IOException {
FILE_UTILS.copyFile(sourceFile, destFile);
} Deprecated! since - 1.4.x
Convenience method to copy a file from a source to a destination.
No filtering is performed. |
public void copyFile(File sourceFile,
File destFile) throws IOException {
FILE_UTILS.copyFile(sourceFile, destFile);
} Deprecated! since - 1.4.x
Convenience method to copy a file from a source to a destination.
No filtering is performed. |
public void copyFile(String sourceFile,
String destFile,
boolean filtering) throws IOException {
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null);
} 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(File sourceFile,
File destFile,
boolean filtering) throws IOException {
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null);
} 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(String sourceFile,
String destFile,
boolean filtering,
boolean overwrite) throws IOException {
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null, 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(File sourceFile,
File destFile,
boolean filtering,
boolean overwrite) throws IOException {
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null, 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(String sourceFile,
String destFile,
boolean filtering,
boolean overwrite,
boolean preserveLastModified) throws IOException {
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null, overwrite, 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 copyFile(File sourceFile,
File destFile,
boolean filtering,
boolean overwrite,
boolean preserveLastModified) throws IOException {
FILE_UTILS.copyFile(sourceFile, destFile,
filtering ? globalFilters : null, overwrite, 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(Project other) {
PropertyHelper.getPropertyHelper(this).copyInheritedProperties(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
copyUserProperties . |
public void copyUserProperties(Project other) {
PropertyHelper.getPropertyHelper(this).copyUserProperties(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
copyInheritedProperties . |
public AntClassLoader createClassLoader(Path path) {
return AntClassLoader
.newAntClassLoader(getClass().getClassLoader(), this, path, true);
}
Factory method to create a class loader for loading classes from
a given path. |
public AntClassLoader createClassLoader(ClassLoader parent,
Path path) {
return AntClassLoader.newAntClassLoader(parent, this, path, true);
}
Factory method to create a class loader for loading classes from
a given path. |
public Object createDataType(String typeName) throws BuildException {
return ComponentHelper.getComponentHelper(this).createDataType(typeName);
}
Create a new instance of a data type. |
public Project createSubProject() {
Project subProject = null;
try {
subProject = (Project) (getClass().newInstance());
} catch (Exception e) {
subProject = new Project();
}
initSubProject(subProject);
return subProject;
}
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. |
public Task createTask(String taskType) throws BuildException {
return ComponentHelper.getComponentHelper(this).createTask(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 |
public int defaultInput(byte[] buffer,
int offset,
int length) throws IOException {
if (defaultInputStream != null) {
System.out.flush();
return defaultInputStream.read(buffer, offset, length);
} else {
throw new EOFException("No input provided for project");
}
}
Read data from the default input stream. If no default has been
specified, System.in is used. |
public void demuxFlush(String output,
boolean isError) {
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);
}
}
}
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. |
public int demuxInput(byte[] buffer,
int offset,
int length) throws IOException {
Task task = getThreadTask(Thread.currentThread());
if (task == null) {
return defaultInput(buffer, offset, length);
} else {
return task.handleInput(buffer, offset, length);
}
}
Demux an input request to the correct task. |
public void demuxOutput(String output,
boolean isWarning) {
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);
}
}
}
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. |
public void executeSortedTargets(Vector sortedTargets) throws BuildException {
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;
}
}
Execute a Vector of sorted targets. |
public void executeTarget(String targetName) throws BuildException {
// 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));
}
Execute the specified target and any targets it depends on. |
public void executeTargets(Vector names) throws BuildException {
setUserProperty(MagicNames.PROJECT_INVOKED_TARGETS,
CollectionUtils.flattenToString(names));
getExecutor().executeTargets(this,
(String[]) (names.toArray(new String[names.size()])));
}
Execute the specified sequence of targets, and the targets
they depend on. |
public void fireBuildFinished(Throwable exception) {
BuildEvent event = new BuildEvent(this);
event.setException(exception);
BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].buildFinished(event);
}
// Inform IH to clear the cache
IntrospectionHelper.clearCache();
}
Send a "build finished" event to the build listeners
for this project. |
public void fireBuildStarted() {
BuildEvent event = new BuildEvent(this);
BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].buildStarted(event);
}
}
Send a "build started" event
to the build listeners for this project. |
protected void fireMessageLogged(Project project,
String message,
int priority) {
fireMessageLogged(project, message, null, priority);
}
Send a "message logged" project level event
to the build listeners for this project. |
protected void fireMessageLogged(Target target,
String message,
int priority) {
fireMessageLogged(target, message, null, priority);
}
Send a "message logged" target level event
to the build listeners for this project. |
protected void fireMessageLogged(Task task,
String message,
int priority) {
fireMessageLogged(task, message, null, priority);
}
Send a "message logged" task level event
to the build listeners for this project. |
protected void fireMessageLogged(Project project,
String message,
Throwable throwable,
int priority) {
BuildEvent event = new BuildEvent(project);
event.setException(throwable);
fireMessageLoggedEvent(event, message, priority);
}
Send a "message logged" project level event
to the build listeners for this project. |
protected void fireMessageLogged(Target target,
String message,
Throwable throwable,
int priority) {
BuildEvent event = new BuildEvent(target);
event.setException(throwable);
fireMessageLoggedEvent(event, message, priority);
}
Send a "message logged" target level event
to the build listeners for this project. |
protected void fireMessageLogged(Task task,
String message,
Throwable throwable,
int priority) {
BuildEvent event = new BuildEvent(task);
event.setException(throwable);
fireMessageLoggedEvent(event, message, priority);
}
Send a "message logged" task level event
to the build listeners for this project. |
public void fireSubBuildFinished(Throwable exception) {
BuildEvent event = new BuildEvent(this);
event.setException(exception);
BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
if (currListeners[i] instanceof SubBuildListener) {
((SubBuildListener) currListeners[i]).subBuildFinished(event);
}
}
}
Send a "subbuild finished" event to the build listeners for
this project. |
public void fireSubBuildStarted() {
BuildEvent event = new BuildEvent(this);
BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
if (currListeners[i] instanceof SubBuildListener) {
((SubBuildListener) currListeners[i]).subBuildStarted(event);
}
}
}
Send a "subbuild started" event to the build listeners for
this project. |
protected void fireTargetFinished(Target target,
Throwable exception) {
BuildEvent event = new BuildEvent(target);
event.setException(exception);
BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].targetFinished(event);
}
}
Send a "target finished" event to the build listeners
for this project. |
protected void fireTargetStarted(Target target) {
BuildEvent event = new BuildEvent(target);
BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].targetStarted(event);
}
}
Send a "target started" event to the build listeners
for this project. |
protected void fireTaskFinished(Task task,
Throwable exception) {
registerThreadTask(Thread.currentThread(), null);
System.out.flush();
System.err.flush();
BuildEvent event = new BuildEvent(task);
event.setException(exception);
BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].taskFinished(event);
}
}
Send a "task finished" event to the build listeners for this
project. |
protected void fireTaskStarted(Task task) {
// register this as the current task on the current thread.
registerThreadTask(Thread.currentThread(), task);
BuildEvent event = new BuildEvent(task);
BuildListener[] currListeners = listeners;
for (int i = 0; i < currListeners.length; i++) {
currListeners[i].taskStarted(event);
}
}
Send a "task started" event to the build listeners
for this project. |
public File getBaseDir() {
if (baseDir == null) {
try {
setBasedir(".");
} catch (BuildException ex) {
ex.printStackTrace();
}
}
return baseDir;
}
Return the base directory of the project as a file object. |
public Vector getBuildListeners() {
synchronized (listenersLock) {
Vector r = new Vector(listeners.length);
for (int i = 0; i < listeners.length; i++) {
r.add(listeners[i]);
}
return r;
}
}
Return a copy of the list of build listeners for the project. |
public Map getCopyOfDataTypeDefinitions() {
return new HashMap(getDataTypeDefinitions());
}
Return the current datatype definition map. The returned
map is a copy pf the "live" definitions. |
public Map getCopyOfReferences() {
return new HashMap(references);
}
Return a map of the references in the project (String to
Object). The returned hashtable is a copy of the
"live" references. |
public Map getCopyOfTargets() {
return new HashMap(targets);
}
Return the map of targets. The returned map
is a copy of the "live" targets. |
public Map getCopyOfTaskDefinitions() {
return new HashMap(getTaskDefinitions());
}
Return the current task definition map. The returned map is a
copy of the "live" definitions. |
public ClassLoader getCoreLoader() {
return coreLoader;
}
Return the core classloader to use for this project.
This may be null, indicating that
the parent classloader should be used. |
public Hashtable getDataTypeDefinitions() {
return ComponentHelper.getComponentHelper(this).getDataTypeDefinitions();
}
Return the current datatype definition hashtable. The returned
hashtable is "live" and so should not be modified. |
public InputStream getDefaultInputStream() {
return defaultInputStream;
}
Get this project's input stream. |
public String getDefaultTarget() {
return defaultTarget;
}
Return the name of the default target of the project. |
public String getDescription() {
if (description == null) {
description = Description.getDescription(this);
}
return description;
}
Return the project description, if one has been set. |
public String getElementName(Object element) {
return ComponentHelper.getComponentHelper(this).getElementName(element);
}
|
public Executor getExecutor() {
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;
}
Get this Project's Executor (setting it if necessary). |
public Hashtable getFilters() {
// we need to build the hashtable dynamically
return globalFilterSet.getFilterHash();
} Deprecated! since - 1.4.x
Use getGlobalFilterSet().getFilterHash().
Return a hashtable of global filters, mapping tokens to values. |
public FilterSet getGlobalFilterSet() {
return globalFilterSet;
}
Return the set of global filters. |
public Hashtable getInheritedProperties() {
return PropertyHelper.getPropertyHelper(this).getInheritedProperties();
}
Return a copy of the inherited property hashtable. |
public InputHandler getInputHandler() {
return inputHandler;
}
Retrieve the current input handler. |
public static String getJavaVersion() {
return JavaEnvUtils.getJavaVersion();
} 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 getName() {
return name;
}
Return the project name, if one has been set. |
public static Project getProject(Object o) {
if (o instanceof ProjectComponent) {
return ((ProjectComponent) o).getProject();
}
try {
Method m = o.getClass().getMethod("getProject", (Class[]) null);
if (Project.class == m.getReturnType()) {
return (Project) m.invoke(o, (Object[]) null);
}
} catch (Exception e) {
//too bad
}
return null;
}
Get the Project instance associated with the specified object. |
public Hashtable getProperties() {
return PropertyHelper.getPropertyHelper(this).getProperties();
}
Return a copy of the properties table. |
public String getProperty(String propertyName) {
Object value = PropertyHelper.getPropertyHelper(this).getProperty(propertyName);
return value == null ? null : String.valueOf(value);
}
Return the value of a property, if it is set. |
public Object getReference(String key) {
Object ret = references.get(key);
if (ret != null) {
return ret;
}
if (!key.equals(MagicNames.REFID_PROPERTY_HELPER)) {
try {
if (PropertyHelper.getPropertyHelper(this).containsProperties(key)) {
log("Unresolvable reference " + key
+ " might be a misuse of property expansion syntax.", MSG_WARN);
}
} catch (Exception e) {
//ignore
}
}
return ret;
}
Look up a reference by its key (ID). |
public Hashtable getReferences() {
return references;
}
Return a map of the references in the project (String to Object).
The returned hashtable is "live" and so must not be modified. |
public Resource getResource(String name) {
return new FileResource(getBaseDir(), name);
}
Resolve the file relative to the project's basedir and return it as a
FileResource. |
public Hashtable getTargets() {
return targets;
}
Return the hashtable of targets. The returned hashtable
is "live" and so should not be modified. |
public Hashtable getTaskDefinitions() {
return ComponentHelper.getComponentHelper(this).getTaskDefinitions();
}
Return the current task definition hashtable. The returned hashtable is
"live" and so should not be modified. |
public Task getThreadTask(Thread thread) {
synchronized(threadTasks) {
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;
}
}
Get the current task associated with a thread, if any. |
public Hashtable getUserProperties() {
return PropertyHelper.getPropertyHelper(this).getUserProperties();
}
Return a copy of the user property hashtable. |
public String getUserProperty(String propertyName) {
return (String) PropertyHelper.getPropertyHelper(this).getUserProperty(propertyName);
}
Return the value of a user property, if it is set. |
public boolean hasReference(String key) {
return references.containsKey(key);
}
Does the project know this reference? |
public void inheritIDReferences(Project parent) {
parentIdProject = parent;
}
Inherit the id references. |
public void init() throws BuildException {
initProperties();
ComponentHelper.getComponentHelper(this).initDefaultDefinitions();
}
Initialise the project.
This involves setting the default task definitions and loading the
system properties. |
public void initProperties() throws BuildException {
setJavaVersionProperty();
setSystemProperties();
setPropertyInternal(MagicNames.ANT_VERSION, Main.getAntVersion());
setAntLib();
}
Initializes the properties. |
public void initSubProject(Project subProject) {
ComponentHelper.getComponentHelper(subProject)
.initSubProject(ComponentHelper.getComponentHelper(this));
subProject.setDefaultInputStream(getDefaultInputStream());
subProject.setKeepGoingMode(this.isKeepGoingMode());
subProject.setExecutor(getExecutor().getSubProjectExecutor());
}
|
public boolean isKeepGoingMode() {
return this.keepGoingMode;
}
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. |
public void log(String message) {
log(message, MSG_INFO);
}
Write a message to the log with the default log level
of MSG_INFO . |
public void log(String message,
int msgLevel) {
log(message, null, msgLevel);
}
Write a project level message to the log with the given log level. |
public void log(String message,
Throwable throwable,
int msgLevel) {
fireMessageLogged(this, message, throwable, msgLevel);
}
Write a project level message to the log with the given log level. |
public void log(Task task,
String message,
int msgLevel) {
fireMessageLogged(task, message, null, msgLevel);
}
Write a task level message to the log with the given log level. |
public void log(Target target,
String message,
int msgLevel) {
log(target, message, null, msgLevel);
}
Write a target level message to the log with the given log level. |
public void log(Task task,
String message,
Throwable throwable,
int msgLevel) {
fireMessageLogged(task, message, throwable, msgLevel);
}
Write a task level message to the log with the given log level. |
public void log(Target target,
String message,
Throwable throwable,
int msgLevel) {
fireMessageLogged(target, message, throwable, msgLevel);
}
Write a target level message to the log with the given log level. |
public void registerThreadTask(Thread thread,
Task task) {
synchronized(threadTasks) {
if (task != null) {
threadTasks.put(thread, task);
threadGroupTasks.put(thread.getThreadGroup(), task);
} else {
threadTasks.remove(thread);
threadGroupTasks.remove(thread.getThreadGroup());
}
}
}
Register a task as the current task for a thread.
If the task is null, the thread's entry is removed. |
public void removeBuildListener(BuildListener listener) {
synchronized (listenersLock) {
// copy on write semantics
for (int i = 0; i < listeners.length; i++) {
if (listeners[i] == listener) {
BuildListener[] newListeners =
new BuildListener[listeners.length - 1];
System.arraycopy(listeners, 0, newListeners, 0, i);
System.arraycopy(listeners, i + 1, newListeners, i,
listeners.length - i - 1);
listeners = newListeners;
break;
}
}
}
}
Remove a build listener from the list. This listener
will no longer be notified of build events for this project. |
public String replaceProperties(String value) throws BuildException {
return PropertyHelper.getPropertyHelper(this).replaceProperties(null, value, null);
}
Replace ${} style constructions in the given value with the
string value of the corresponding data types. |
public File resolveFile(String fileName) {
return FILE_UTILS.resolveFile(baseDir, fileName);
}
|
public File resolveFile(String fileName,
File rootDir) {
return FILE_UTILS.resolveFile(rootDir, fileName);
} Deprecated! since - 1.4.x
|
public void setBaseDir(File baseDir) throws BuildException {
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);
}
Set the base directory for the project, checking that
the given file exists and is a directory. |
public void setBasedir(String baseD) throws BuildException {
setBaseDir(new File(baseD));
}
Set the base directory for the project, checking that
the given filename exists and is a directory. |
public void setCoreLoader(ClassLoader coreLoader) {
this.coreLoader = coreLoader;
}
Set the core classloader for the project. If a null
classloader is specified, the parent classloader should be used. |
public void setDefault(String defaultTarget) {
setUserProperty(MagicNames.PROJECT_DEFAULT_TARGET, defaultTarget);
this.defaultTarget = defaultTarget;
}
Set the default target of the project. |
public void setDefaultInputStream(InputStream defaultInputStream) {
this.defaultInputStream = 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. |
public void setDefaultTarget(String defaultTarget) {
setDefault(defaultTarget);
} Deprecated! since - 1.5.x.
Use setDefault.
Set the default target of the project. |
public void setDescription(String description) {
this.description = description;
}
Set the project description. |
public void setExecutor(Executor e) {
addReference(MagicNames.ANT_EXECUTOR_REFERENCE, e);
}
Set the Executor instance for this Project. |
public void setFileLastModified(File file,
long time) throws BuildException {
FILE_UTILS.setFileLastModified(file, time);
log("Setting modification time for " + file, MSG_VERBOSE);
} 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(String name,
String value) {
PropertyHelper.getPropertyHelper(this).setInheritedProperty(name, 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. |
public void setInputHandler(InputHandler handler) {
inputHandler = handler;
}
|
public void setJavaVersionProperty() throws BuildException {
String javaVersion = JavaEnvUtils.getJavaVersion();
setPropertyInternal(MagicNames.ANT_JAVA_VERSION, javaVersion);
// sanity check
if (!JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_1_4)) {
throw new BuildException("Ant cannot work on Java prior to 1.4");
}
log("Detected Java version: " + javaVersion + " in: "
+ System.getProperty("java.home"), MSG_VERBOSE);
log("Detected OS: " + System.getProperty("os.name"), MSG_VERBOSE);
}
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. |
public void setKeepGoingMode(boolean keepGoingMode) {
this.keepGoingMode = 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. |
public void setName(String name) {
setUserProperty(MagicNames.PROJECT_NAME, name);
this.name = name;
}
Set the name of the project, also setting the user
property ant.project.name. |
public void setNewProperty(String name,
String value) {
PropertyHelper.getPropertyHelper(this).setNewProperty(name, 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. |
public final void setProjectReference(Object obj) {
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.
}
}
Set a reference to this Project on the parameterized object.
Need to set the project before other set/add elements
are called. |
public void setProperty(String name,
String value) {
PropertyHelper.getPropertyHelper(this).setProperty(name, value, true);
}
Set a property. Any existing property of the same name
is overwritten, unless it is a user property. |
public void setSystemProperties() {
Properties systemP = System.getProperties();
Enumeration e = systemP.propertyNames();
while (e.hasMoreElements()) {
String propertyName = (String) e.nextElement();
String value = systemP.getProperty(propertyName);
if (value != null) {
this.setPropertyInternal(propertyName, value);
}
}
}
Add all system properties which aren't already defined as
user properties to the project properties. |
public void setUserProperty(String name,
String value) {
PropertyHelper.getPropertyHelper(this).setUserProperty(name, value);
}
Set a user property, which cannot be overwritten by
set/unset property calls. Any previous value is overwritten. |
public static boolean toBoolean(String s) {
return ("on".equalsIgnoreCase(s)
|| "true".equalsIgnoreCase(s)
|| "yes".equalsIgnoreCase(s));
}
Return the boolean equivalent of a string, which is considered
true if either "on", "true",
or "yes" is found, ignoring case. |
public final Vector topoSort(String root,
Hashtable targetTable) throws BuildException {
return topoSort(new String[] {root}, targetTable, true);
}
Topologically sort a set of targets. Equivalent to calling
topoSort(new String[] {root}, targets, true). |
public final Vector topoSort(String root,
Hashtable targetTable,
boolean returnAll) throws BuildException {
return topoSort(new String[] {root}, targetTable, returnAll);
}
Topologically sort a set of targets. Equivalent to calling
topoSort(new String[] {root}, targets, returnAll). |
public final Vector topoSort(String[] root,
Hashtable targetTable,
boolean returnAll) throws BuildException {
Vector ret = new VectorSet();
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;
}
Topologically sort a set of targets. |
public static String translatePath(String toProcess) {
return FileUtils.translatePath(toProcess);
} Deprecated! since - 1.7
Use FileUtils.translatePath instead.
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. |