ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rob Oxspring" <>
Subject [SUBMIT] FileOrder element for ordering of filesets
Date Tue, 09 Apr 2002 22:57:21 GMT
IIRC at least one of the problems with submitted concatenation tasks in the
past was that ant does not guarentee the order of files within the
concatenated file.  Instead of patching one of the concat tasks (admittedly
where I started) this submission is just a utility to allow file order to be
specified by the user and applied by the task. I'm sure this is useful for
concatenation, it may also be handy for the tar/zip family of tasks and it
might also add an extra aesthetic bonus to the mail task.

User perspective:
The idea is that tasks can be enhanced with a fileorder element that takes
an order attribute defining the order to be used when processing files.
Implementation using an attribute would involve creating an implicit
fileorder object to hold the value.  Various attributes of a file can be
used to specify the order, can be reversed with a '-' prefix, and combined
with ',' symbols.  Currently the supported attributes are

<fileorder order="path,extension,basename"/> - group by directory and then
file extension
<fileorder order="-date"/> - decreasing date order

To access from code:
o   use usual directory scanner approach to find the files in a fileset.
o   use fileOrder.addAll(String []) to queue the files to be sorted (can
queue up several filesets before sorting the lot)
o   when all the files are added use fileOrder.sort() to get a String[] of
the filenames in order.

To add this functionality to existing tasks should therefore be fairly
simple patches.

How it works:
The Java2 Comparator is reimplemented and various implementations are used
to supply the ordering information.  A merge sort is performed by the sort()
method, thus avoiding the Java2 dependancies of Collections.sort() or
Arrays.sort().  These should probably be revised when the move to Java2 is

Whats included:
o.a.t.a.util.FileOrder - the class doing the work.* - the classes doing the comparisons

o.a.t.a.util.FileOrderTest - tests the attribute validation and general
sorting - tests each comparator individually

Future work:
Convert to Java2 with Ant2
Patch ordering into existing tasks
Add docs
Comparators are hardcoded at present - should be customisable eventually.

So, anyone think that this is useful? is it worth me writing the docs?

Hope its useful,


View raw message