Hello,

Stefan Bodewig wrote:
On 07 Feb 2003, Stefan Bodewig <[EMAIL PROTECTED]> wrote:
(6) ZipScanner now really parses the archive instead of returning
the archive itself in getIncludedFiles.


I have an issue with the implementation, not with the API.

ZipScanner now wants a Task instance to log to.  This should probably
be a ProjectComponent so that ZipFileSet can point to itself in
getDirectoryScanner.  Or maybe it should get the Project instance
directly?

I'm writing a generic Velocity to Ant logging adapter initially to use for http://vpp.sourceforge.net. I just ran into a similar issue when logging from a filter.


Since filters must be a subclass of java.io.FilterReader, they can't also extend ProjectComponent. As a result, they only have access to the Project, not the owning task. Logging through the Project is not good because the output is not associated with the calling Task.

After much head scratching and looking around, I eventually found this seems to work:
LogSystem logger = null;
Task owningTask =
getProject().getThreadTask(Thread.currentThread());
if (owningTask != null) {
logger = new AntLogSystem(owningTask);
}
else {
logger = new AntLogSystem(getProject());
}


So if you're willing to pass Project into ZipScanner, it could log against the owning Task.

-Bill



Reply via email to