在蚂蚁,我怎么能测试一个财产给定值结束? [英] In Ant, how can I test if a property ends with a given value?

查看:196
本文介绍了在蚂蚁,我怎么能测试一个财产给定值结束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在蚂蚁,我怎么能测试一个财产给定值结束?

In Ant, how can I test if a property ends with a given value?

例如

 <property name="destdir" 
     value="D:\FeiLong Soft\Essential\Development\repository\org\springframework\spring-beans" />

如何测试如果 $ {DESTDIR} 结尾春豆

补充:

在我的蚂蚁的contrib-1.0b3.jar,没有'的endsWith任务~~

In my ant-contrib-1.0b3.jar, without 'endswith' task~~

推荐答案

,蚂蚁的Contrib含有大量的不错的东西,我用它严重。

As Matteo, Ant-Contrib contains a lot of nice stuff, and I use it heavily.

然而,在这种情况下,可以简单地使用&LT;&基名GT; 任务:

However, in this case can simply use the <basename> task:

<basename property="basedir.name" file="${destdir}"/>
<condition property="ends.with.spring-beans">
   <equals arg1="spring-beans" arg2="${basedir.name}"/>
<condition>

属性 $ {ends.with.spring豆} 将包含真正如果 $ {DESTDIR} 结束串豆类其它。目标&GT; 如果或除非的参数&LT使用code>任务。

The property ${ends.with.spring-beans} will contain true if ${destdir} ends with string-beans and false otherwise. You could use it in the if or unless parameter of the <target> task.

这篇关于在蚂蚁,我怎么能测试一个财产给定值结束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆