ant-contrib的最新版本是ant-contrib-1.0b3.jar
http://ant-contrib.sourceforge.net/tasks/tasks/more_conditions.html
本文档显示endsWith条件
但是我使用的是ant 1.8.2和ant-contrib-1.0b3.jar,我找不到endsWith条件
<if>
<endswith string="D:\FeiLong Soft\Essential\Development\repository\org\springframework\spring-beans" with="spring-beans" />
<then>
<echo>equals</echo>
</then>
<else>
<echo>not equals</echo>
</else>
</if>但结果是:
BUILD FAILED
E:\Workspaces\feilong\feilong-platform\tools\feilong-tools-ant\build.xml:32: if
doesn't support the nested "endswith" element.
Total time: 1 second发布于 2015-04-15 15:55:10
当检查来自antcontrib (版本1.0b2或1.0b3)的源代码,特别是net/sf/antcontrib/antcontrib.properties和../antlib.xml时,你会看到,没有startsWith或endsWith条件,尽管在antcontrib manual中提到了它。
这两个条件源于Antelope project,它为运行ant和几个ant任务提供了一个UI。几年前就有了合并AntContrib的计划,参见Antelope Tasks Merging with AntContrib和Antelope项目网站:
的Antelope Project还提供了一组额外的任务,这些任务提供了Ant分发的标准任务中没有的功能。将Antelope任务与AntContrib项目合并的工作正在进行中。
..。
Ant-Contrib项目是Apache Ant的一组任务(甚至可能是类型和其他工具)。一些Antelope任务现在是该项目的一部分。
但不知何故,这些合并计划停滞不前,从未正确完成,而且Antcontrib似乎也死了- latest release 1.0b3 from 2006-11-02
无论如何,您可以将ant matches condition与antcontrib一起使用:
<project>
<!-- Import AntContrib -->
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property name="foo" value="D:\FeiLong Soft\Essential\Development\repository\org\springframework\spring-beans"/>
<if>
<matches string="${foo}" pattern="^.+spring-beans$"/>
<then>
<echo>equals</echo>
</then>
<else>
<echo>not equals</echo>
</else>
</if>
</project>或者是Antelope ant tasks。
发布于 2015-04-15 04:44:35
我在使用"startwith“时也遇到了同样的问题,并且没有找到解决方案。我不明白“包含”工作的原因,但是“开始于”和“结束于”不是这样。
<if>
<contains string="a sample string" substring="sample" />
<then>
<echo>match</echo>
</then>
<else>
<echo>not match</echo>
</else>
</if>https://stackoverflow.com/questions/13670197
复制相似问题