ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject Re: custom selector which examines multiple files before returning an answer
Date Tue, 07 Jun 2005 15:05:51 GMT
(excuse the top-post)

In Ant 1.7 you will be able to do this using
ResourceCollections which include the ability to sort
as well as select.  The correct approach would then be
very like what you are proposing:

- select files matching the specified name, store as
reference "foo".
- reverse-sort "foo" by date.
- restrict the sorted collection to the first returned
(mental note on my part to write a <first>
resourceselector) and store as reference "bar".
- <delete> the resourcecollection that is the
difference between "foo" and "bar" (resource
collections will include such "set logic" collections
as this).

Unfortunately this doesn't help you particularly now,
especially as even the HEAD version of many Ant tasks
(including <delete>) does not yet support resource
collections.  My apologies.

-Matt

--- "Frode E. Moe" <frode@CoreTrek.no> wrote:

> Hi, I'm trying to implement a way to detect
> duplicate .jar files (where
> only the version differ) and delete all duplicates
> except the newest.
> The way I hoped to implement this was to use the
> <delete> task together
> with a custom Selector, like this:
>   <delete>
>     <fileset dir="lib" includes="**/*.jar">
>       <custom
> classname="com.coretrek.DuplicateSElector" />
>     </fileset>
>   </delete>
> 
> Unfortunately this doesn't seem to work out very
> well, because the
> FileSelector interface's "isSelected()" requires my
> class to provide an
> answer for each file on the fly, while I need to
> read and sort 
> the entire "candidate" fileset before selecting out
> the dupes.
> 
> Is there another way to implement a FileSet
> filtering mechanism that
> would work for this purpose, or do I have to write a
> custom
> "DeleteDuplicates" task?
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message