首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用ant-contrib,如何使用"endsWith"?

使用ant-contrib,如何使用"endsWith"?
EN

Stack Overflow用户
提问于 2012-12-02 22:28:25
回答 2查看 3.1K关注 0票数 4

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

代码语言:javascript
复制
    <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>

但结果是:

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-04-15 15:55:10

当检查来自antcontrib (版本1.0b2或1.0b3)的源代码,特别是net/sf/antcontrib/antcontrib.properties../antlib.xml时,你会看到,没有startsWithendsWith条件,尽管在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一起使用:

代码语言:javascript
复制
<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

票数 4
EN

Stack Overflow用户

发布于 2015-04-15 04:44:35

我在使用"startwith“时也遇到了同样的问题,并且没有找到解决方案。我不明白“包含”工作的原因,但是“开始于”和“结束于”不是这样。

代码语言:javascript
复制
<if>
    <contains string="a sample string" substring="sample" />
    <then>
        <echo>match</echo>
    </then>
    <else>
        <echo>not match</echo>
    </else>
</if>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13670197

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档