ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject Re: Loading files into concat in a certain order
Date Tue, 24 Jul 2007 15:23:31 GMT

--- Alex Egg <eggie5@gmail.com> wrote:

> I'm looking at the (dismal) ant docs on resources
> and sort, but I can't
> figure out how to use it on my file set:
> <concat destfile="${temp}/s3/management.css">
>       <fileset dir="${temp}/assets/min/css/"
> includes="*.css"/>
>     </concat>
> 
> I just want to sort those files by name so they go
> into concat alphabeticly.
> My files are named 1styles.css, 2styles.css,
> 3styles.css, etc...
> 
> How can I do this?

As the docs say, <sort> operates on a nested resource
collection, here your fileset:

<sort>
  <fileset dir="${temp}/assets/min/css/"
includes="*.css" />
</sort>

This will sort the resources according to their
natural sort order.  In this case your sorted resource
collection is a fileset, thus you know it contains
only file resources.  These will be sorted according
to the underlying File objects' natural sort order,
which should accomplish what you want.  If there was
some other order you wanted to impose you should be
able to specify nested comparators as described in the
documentation; the caveat referenced in the doc is
that the built-in resource comparators are "stored" in
an "internal" antlib to avoid namespace collisions
with other, similar types, e.g.:

<sort
xmlns:rcmp="antlib:org.apache.tools.ant.types.resources.comparators">
  <fileset refid="whatever" />
  <rcmp:size />
  <rcmp:reverse>
    <date /><!-- I think that's right; inherits ns
from parent -->
  </rcmp:reverse>
</sort>

Does that help?

-Matt

P.S. feel free to submit documentation enhancements
once, as a user, you have arrived at an example you
feel might be useful to prevent others encountering
the same confusion you did!

> 
> Alex
> 
> On 7/23/07, Matt Benson <gudnabrsam@yahoo.com>
> wrote:
> >
> >
> > --- Alex Egg <eggie5@gmail.com> wrote:
> >
> > > I need to load some CSS files into the concat
> task,
> > > but they need to be a
> > > certain order. How should I do this? Maybe
> number
> > > the file names? Is there
> > > any build in fileset functionality for this?
> > > Alex
> > >
> >
> > In Ant 1.7+, you can use any resource collection
> with
> > <concat>.  If you need to specify an arbitrary
> order,
> > use a <path> or a <resources> collection.  If you
> can
> > sort them in some way, look at the <sort> resource
> > collection.
> >
> > HTH,
> > Matt
> >
> >
> >
> >
>
____________________________________________________________
> > ________________________
> > Pinpoint customers who are looking for what you
> sell.
> > http://searchmarketing.yahoo.com/
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> > For additional commands, e-mail:
> user-help@ant.apache.org
> >
> >
> 



       
____________________________________________________________________________________
Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.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