ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Conor MacNeill <co...@cortexebusiness.com.au>
Subject Re: cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/types DirSetTest.java
Date Fri, 05 Apr 2002 13:31:53 GMT
Stefan Bodewig wrote:

> because the result would be counterintuitive.
> 
> <dirset id="dirs" dir="." />
> 
> is supposed to contain all directories under basedir.
> 
> <jar>
>   <fileset refid="dirs" />
> </jar>
> 
> will include all files, including the directories will happen by
> accident.
> 
> The problem is, that FileSet doesn't really encapsulate files, but
> only a DirectoryScanner - and it is up to the task to decide whether
> they want to use the files or directories or even both.
> 
> If you pass a dirset as a fileset to a task that is not aware of the
> DirSet class (read, all tasks except pathconvert), they will use
> getIncludedFiles().
> 
> An ugly(? - yes, I think it would be ugly) hack to make dirset work
> like ones expectation would be to override getDirectoryScanner in
> DirSet so that it returns a DirectoryScanner that was a wrapper around
> the DirectoryScanner returned by FileSet and reroutes get*Files to
> get*Directories and vice versa.  That way, tasks would call
> getIncludedFiles and get the directories instead.
> 

OK, I see. Nevertheless, the check that prevented this usage had to go, since I 
think it was too limiting to fileset subclasses.

 From your reasoning, I would say that a DirSet should probably not be a 
subclass of FileSet, since you are saying it can't really be passed to someone 
expecting a FileSet (Liskov).

I think the best thing may be to have DirSet provide a DirectoryScanner subclass 
where getIncludedFiles returns nothing since by definition a DirSet does not 
include files :-). Rerouting get*Files to get*Directories may not be a good idea.

Conor


--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message