in src/main/org/apache/tools/ant/taskdefs/SubAnt.java [188:274]
public void execute() {
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 (String filename : filenames) {
File file = null;
String subdirPath = null;
Throwable thrownException = null;
try {
File directory = null;
file = new File(filename);
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);
log(StringUtils.getStackTrace(thrownException), Project.MSG_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;
}
}