1

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

4

2 回答 2

2

使用资源,即回显最新创建的目录:

按名称分类 :

<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>

按日期排序:

<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>

资源集合随 Ant 1.7 一起提供,可以与<copy>, <move>.. 等结合使用。

于 2013-04-17T21:04:55.053 回答
1

由于您的构建(以及目录名称)实际上也按字母顺序排序

ls -rd | tail -n 1

应该给你最新的。

于 2013-04-17T16:06:03.530 回答