Methods Summary |
---|
public void | add(org.apache.tools.ant.types.ResourceCollection rc)Adds a resource collection to the implicit build path.
getBuildpath().add(rc);
|
public void | addConfiguredTarget(org.apache.tools.ant.taskdefs.Ant.TargetElement t)Add a target to this Ant invocation.
String name = t.getName();
if ("".equals(name)) {
throw new BuildException("target name must not be empty");
}
targets.add(t);
|
public void | addDirset(org.apache.tools.ant.types.DirSet set)Adds a directory set to the implicit build path.
Note that the directories will be added to the build path
in no particular order, so if order is significant, one should
use a file list instead!
add(set);
|
public void | addFilelist(org.apache.tools.ant.types.FileList list)Adds an ordered file list to the implicit build path.
Note that contrary to file and directory sets, file lists
can reference non-existent files or directories!
add(list);
|
public void | addFileset(org.apache.tools.ant.types.FileSet set)Adds a file set to the implicit build path.
Note that the directories will be added to the build path
in no particular order, so if order is significant, one should
use a file list instead!
add(set);
|
public void | addProperty(Property p)Corresponds to <ant> 's
nested <property> element.
properties.addElement(p);
|
public void | addPropertyset(org.apache.tools.ant.types.PropertySet ps)Corresponds to <ant> 's
nested <propertyset> element.
propertySets.addElement(ps);
|
public void | addReference(Ant.Reference r)Corresponds to <ant> 's
nested <reference> element.
references.addElement(r);
|
private static void | copyProperty(Property to, Property from)Assigns an Ant property to another.
to.setName(from.getName());
if (from.getValue() != null) {
to.setValue(from.getValue());
}
if (from.getFile() != null) {
to.setFile(from.getFile());
}
if (from.getResource() != null) {
to.setResource(from.getResource());
}
if (from.getPrefix() != null) {
to.setPrefix(from.getPrefix());
}
if (from.getRefid() != null) {
to.setRefid(from.getRefid());
}
if (from.getEnvironment() != null) {
to.setEnvironment(from.getEnvironment());
}
if (from.getClasspath() != null) {
to.setClasspath(from.getClasspath());
}
|
private Ant | createAntTask(java.io.File directory)Creates the <ant> task configured to run a specific target.
Ant antTask = new Ant(this);
antTask.init();
if (subTarget != null && subTarget.length() > 0) {
antTask.setTarget(subTarget);
}
if (output != null) {
antTask.setOutput(output);
}
if (directory != null) {
antTask.setDir(directory);
}
antTask.setInheritAll(inheritAll);
for (Enumeration i = properties.elements(); i.hasMoreElements();) {
copyProperty(antTask.createProperty(), (Property) i.nextElement());
}
for (Enumeration i = propertySets.elements(); i.hasMoreElements();) {
antTask.addPropertyset((PropertySet) i.nextElement());
}
antTask.setInheritRefs(inheritRefs);
for (Enumeration i = references.elements(); i.hasMoreElements();) {
antTask.addReference((Ant.Reference) i.nextElement());
}
return antTask;
|
public org.apache.tools.ant.types.Path | createBuildpath()Creates a nested build path, and add it to the implicit build path.
return getBuildpath().createPath();
|
public Path.PathElement | createBuildpathElement()Creates a nested <buildpathelement> ,
and add it to the implicit build path.
return getBuildpath().createPathElement();
|
public void | execute()Runs the various sub-builds.
if (buildpath == null) {
throw new BuildException("No buildpath specified");
}
final String[] filenames = buildpath.list();
final int count = filenames.length;
if (count < 1) {
log("No sub-builds to iterate on", Project.MSG_WARN);
return;
}
/*
//REVISIT: there must be cleaner way of doing this, if it is merited at all
if (subTarget == null) {
subTarget = getOwningTarget().getName();
}
*/
BuildException buildException = null;
for (int i = 0; i < count; ++i) {
File file = null;
String subdirPath = null;
Throwable thrownException = null;
try {
File directory = null;
file = new File(filenames[i]);
if (file.isDirectory()) {
if (verbose) {
subdirPath = file.getPath();
log("Entering directory: " + subdirPath + "\n", Project.MSG_INFO);
}
if (genericantfile != null) {
directory = file;
file = genericantfile;
} else {
file = new File(file, antfile);
}
}
execute(file, directory);
if (verbose && subdirPath != null) {
log("Leaving directory: " + subdirPath + "\n", Project.MSG_INFO);
}
} catch (RuntimeException ex) {
if (!(getProject().isKeepGoingMode())) {
if (verbose && subdirPath != null) {
log("Leaving directory: " + subdirPath + "\n", Project.MSG_INFO);
}
throw ex; // throw further
}
thrownException = ex;
} catch (Throwable ex) {
if (!(getProject().isKeepGoingMode())) {
if (verbose && subdirPath != null) {
log("Leaving directory: " + subdirPath + "\n", Project.MSG_INFO);
}
throw new BuildException(ex);
}
thrownException = ex;
}
if (thrownException != null) {
if (thrownException instanceof BuildException) {
log("File '" + file
+ "' failed with message '"
+ thrownException.getMessage() + "'.", Project.MSG_ERR);
// only the first build exception is reported
if (buildException == null) {
buildException = (BuildException) thrownException;
}
} else {
log("Target '" + file
+ "' failed with message '"
+ thrownException.getMessage() + "'.", Project.MSG_ERR);
thrownException.printStackTrace(System.err);
if (buildException == null) {
buildException =
new BuildException(thrownException);
}
}
if (verbose && subdirPath != null) {
log("Leaving directory: " + subdirPath + "\n", Project.MSG_INFO);
}
}
}
// check if one of the builds failed in keep going mode
if (buildException != null) {
throw buildException;
}
|
private void | execute(java.io.File file, java.io.File directory)Runs the given target on the provided build file.
if (!file.exists() || file.isDirectory() || !file.canRead()) {
String msg = "Invalid file: " + file;
if (failOnError) {
throw new BuildException(msg);
}
log(msg, Project.MSG_WARN);
return;
}
ant = createAntTask(directory);
String antfilename = file.getAbsolutePath();
ant.setAntfile(antfilename);
for (int i = 0; i < targets.size(); i++) {
TargetElement targetElement = (TargetElement) targets.get(i);
ant.addConfiguredTarget(targetElement);
}
try {
ant.execute();
} catch (BuildException e) {
if (failOnError) {
throw e;
}
log("Failure for target '" + subTarget
+ "' of: " + antfilename + "\n"
+ e.getMessage(), Project.MSG_WARN);
} catch (Throwable e) {
if (failOnError) {
throw new BuildException(e);
}
log("Failure for target '" + subTarget
+ "' of: " + antfilename + "\n"
+ e.toString(),
Project.MSG_WARN);
} finally {
ant = null;
}
|
private org.apache.tools.ant.types.Path | getBuildpath()Gets the implicit build path, creating it if null .
if (buildpath == null) {
buildpath = new Path(getProject());
}
return buildpath;
|
public void | handleErrorFlush(java.lang.String output)Pass output sent to System.err to the new project.
if (ant != null) {
ant.handleErrorFlush(output);
} else {
super.handleErrorFlush(output);
}
|
public void | handleErrorOutput(java.lang.String output)Pass output sent to System.err to the new project.
if (ant != null) {
ant.handleErrorOutput(output);
} else {
super.handleErrorOutput(output);
}
|
public void | handleFlush(java.lang.String output)Pass output sent to System.out to the new project.
if (ant != null) {
ant.handleFlush(output);
} else {
super.handleFlush(output);
}
|
public int | handleInput(byte[] buffer, int offset, int length)Process input into the ant task
if (ant != null) {
return ant.handleInput(buffer, offset, length);
} else {
return super.handleInput(buffer, offset, length);
}
|
public void | handleOutput(java.lang.String output)Pass output sent to System.out to the new project.
if (ant != null) {
ant.handleOutput(output);
} else {
super.handleOutput(output);
}
|
public void | setAntfile(java.lang.String antfile)This method builds the file name to use in conjunction with directories.
Defaults to "build.xml".
If genericantfile is set, this attribute is ignored.
this.antfile = antfile;
|
public void | setBuildpath(org.apache.tools.ant.types.Path s)Set the buildpath to be used to find sub-projects.
getBuildpath().append(s);
|
public void | setBuildpathRef(org.apache.tools.ant.types.Reference r)Buildpath to use, by reference.
createBuildpath().setRefid(r);
|
public void | setFailonerror(boolean failOnError)Sets whether to fail with a build exception on error, or go on.
this.failOnError = failOnError;
|
public void | setGenericAntfile(java.io.File afile)This method builds a file path to use in conjunction with directories.
Use genericantfile , in order to run the same build file
with different basedirs.
If this attribute is set, antfile is ignored.
this.genericantfile = afile;
|
public void | setInheritall(boolean b)Corresponds to <ant> 's
inheritall attribute.
this.inheritAll = b;
|
public void | setInheritrefs(boolean b)Corresponds to <ant> 's
inheritrefs attribute.
this.inheritRefs = b;
|
public void | setOutput(java.lang.String s)Corresponds to <ant> 's
output attribute.
this.output = s;
|
public void | setTarget(java.lang.String target)The target to call on the different sub-builds. Set to "" to execute
the default target.
this.subTarget = target;
|
public void | setVerbose(boolean on)Enable/ disable verbose log messages showing when each sub-build path is entered/ exited.
The default value is "false".
this.verbose = on;
|