[英]Use Ant to find file with latest version number
I want to use ant to find the file with the latest version number. 我想使用ant查找具有最新版本号的文件。 For example, I have a file directory named tomcat with the following files:
例如,我有一个名为tomcat的文件目录,其中包含以下文件:
I want ant to determine that apache-tomcat-6.0.39.zip is the latest file. 我希望蚂蚁确定apache-tomcat-6.0.39.zip是最新文件。 Is there a way to do this?
有没有办法做到这一点?
Thanks! 谢谢!
Use resource collections, see last and sort . 使用资源集合,请参阅last和sort 。 fe :
fe:
<project>
<path id="foo">
<last>
<sort>
<fileset dir="C:/some/path" includes="**/apache-tomcat-*.zip"/>
</sort>
</last>
</path>
<echo>$${foo} => ${toString:foo}</echo>
</project>
output : 输出:
[echo] ${foo} => C:\some\path\apache-tomcat-6.0.39.zip
<pathconvert>
to get file names from the relevant <fileset>
. <pathconvert>
从相关的<fileset>
获取文件名。 <sortlist>
to sort the filenames in natural String order
. <sortlist>
以natural String order
对文件名进行排序。 try this: 尝试这个:
<fileset dir="${your.base.dir}" id="one">
<include name="**/apache-tomcat-.*.zip"/>
</fileset>
<pathconvert property="orig.list" refid="one" pathsep=","/>
<sortlist property="sorted.list" value="${orig.list}" delimiter="," />
<propertyregex property="result" input="${sorted.list}" regexp=",?([^,]+?)$" select="\1"/>
inputList: <property name="one" value="ab-2,ab-5,ab-1,ab-3,ab-4"/>
inputList:
<property name="one" value="ab-2,ab-5,ab-1,ab-3,ab-4"/>
outputList: [echo] ab-5
outputList:
[echo] ab-5
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.