File baseDir = set.getDir(getProject());
DirectoryScanner scanner = set.getDirectoryScanner(getProject());
// create a non recursive file set for each included directory
for (String fileName : scanner.getIncludedDirectories()) {
FileSet fileSet = new FileSet();
fileSet.setDir(new File(baseDir, fileName));
fileSet.setIncludes("*.class");
addFileSet(fileSet);
}
}
// Check arguments.
boolean hasFileSet = itsFileSets.size() != 0 || itsDirSets.size() != 0;
if (inputJar != null) {
if (outputJar == null)
throw new BuildException("'outputjar' must be set.");
if (hasFileSet)
throw new BuildException(
"'inputjar' is incompatible with filesets and dirsets");
} else if (!hasFileSet)
throw new BuildException(
"Either attribute 'srcdir' or 'inputjar' must be used or atleast one fileset or dirset must be embedded.",
getLocation());
// Create and configure the weaver.
RetroWeaver weaver = new RetroWeaver(itsVersion);
weaver.setLazy(itsLazy);
weaver.setStripSignatures(stripSignatures);
weaver.setStripAttributes(stripAttributes);
// Set up a listener.
weaver.setListener(new WeaveListener() {
public void weavingStarted(String msg) {
getProject().log(RetroWeaverTask.this, msg, Project.MSG_INFO);
}
public void weavingCompleted(String msg) {
getProject().log(RetroWeaverTask.this, msg, Project.MSG_INFO);
}
public void weavingError(String msg) {
getProject().log(RetroWeaverTask.this, msg, Project.MSG_ERR);
throw new ExitStatusException("weaving error", 1);
}
public void weavingPath(String pPath) {
if (itsVerbose)
getProject().log(RetroWeaverTask.this, "Weaving " + pPath,
Project.MSG_INFO);
}
});
if (verifyClasspath != null && doVerify()) {
List<String> refPath = new ArrayList<String>();
for (String pathItem : verifyClasspath.list()) {
refPath.add(pathItem);
}
if (itsDestDir != null) {
refPath.add(itsDestDir.getPath());
}
RefVerifier rv = new RefVerifier(itsVersion, new EmptyVisitor(), refPath, new VerifierListener() {
public void verifyPathStarted(String msg) {
getProject().log(RetroWeaverTask.this, msg,
Project.MSG_INFO);
}
public void verifyClassStarted(String msg) {
if (itsVerbose)
getProject().log(RetroWeaverTask.this, msg,
Project.MSG_INFO);
}
public void acceptWarning(String msg) {
getProject().log(RetroWeaverTask.this, msg,
Project.MSG_WARN);
}
public void displaySummary(int warningCount) {
String msg = "Verification complete, " + warningCount
+ " warning(s).";
getProject().log(RetroWeaverTask.this, msg,
Project.MSG_WARN);
if (itsFailOnError)
throw new ExitStatusException(Integer
.toString(warningCount)
+ " warning(s)", 1);
}
});
weaver.setVerifier(rv);
}
try {
if (inputJar != null) {
weaver.weaveJarFile(inputJar, outputJar);
} else {
// Weave the files in the filesets.
// Process each fileset.
String[][] fileSets = new String[itsFileSets.size()][];
File[] baseDirs = new File[itsFileSets.size()];
int i = 0;
for (FileSet fileSet : itsFileSets) {
// Create a directory scanner for the fileset.
File baseDir = fileSet.getDir(getProject());
DirectoryScanner scanner = fileSet
.getDirectoryScanner(getProject());
fileSets[i] = scanner.getIncludedFiles();
baseDirs[i++] = baseDir;
}