Reputation: 2025
I have directories that creating by following pattern build_yyyyMMdd_HHmmssSSS
i.e
build_20130304_112343142
build_20130402_102141121
I need to determinate latest created directory in ant build
Does ant has some kind of max function?
Or perhaps you can propose me some another idea?
Thansk
Upvotes: 1
Views: 62
Reputation: 10377
Use resources, i.e. echoing the latest created directory :
sort by name :
<resources id="foobar">
<!-- default last count="1" -->
<last>
<sort>
<name/>
<dirset dir="path/to/rootdir">
<include name="build*" />
</dirset>
</sort>
</last>
</resources>
<echo>${toString:foobar}</echo>
sort by date :
<resources id="foobar">
<!-- default last count="1" -->
<last>
<sort>
<date/>
<dirset dir="path/to/rootdir">
<include name="build*" />
</dirset>
</sort>
</last>
</resources>
<echo>${toString:foobar}</echo>
Resource collections came with Ant 1.7 and may be used in conjunction with <copy>
, <move>
.. etc.
Upvotes: 2
Reputation: 22001
As your builds (and thus directory names) are effectively also ordered alphabetically then
ls -rd | tail -n 1
should give you the latest one.
Upvotes: 1