"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);
// Name space conversion
List<NameSpace> l = new ArrayList<NameSpace>();
for(Namespace n: namespaces) {
l.add(new NameSpace(n.getFrom(), n.getTo()));
}
weaver.addNameSpaces(l);
// 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;
}
weaver.weave(baseDirs, fileSets, itsDestDir);
}
} catch (BuildException ex) {
throw ex;
} catch (Exception ex) {
// unexpected exception