使用ant-contrib,如何使用“endsWith"? [英] Use ant-contrib,how to use "endsWith"?

查看:29
本文介绍了使用ant-contrib,如何使用“endsWith"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 <如果><endswith string="D:\FeiLong Soft\Essential\Development\repository\org\springframework\spring-beans" with="spring-beans"/><然后><echo>等于</echo></然后><其他><echo>不等于</echo></else></如果>

但结果:

构建失败E:\Workspaces\feilong\feilong-platform\tools\feilong-tools-ant\build.xml:32:如果不支持嵌套的endswith"元素.总时间:1秒

解决方案

当检查来自 antcontrib(版本 1.0b2 或 1.0b3)的源时,尤其是 net/sf/antcontrib/antcontrib.properties 和 <代码>../antlib.xml你会看到,没有 startsWithendsWith 条件,尽管它在 antcontrib 手册.

这两个条件源自 Antelope 项目,它提供了一个用于运行 ant 和多个 ant 任务的 UI.多年前有计划将 Antelope 与 AntContrib 合并,参见 Antelope Tasks 与 AntContrib 合并 和 Antelope 项目站点:

<块引用>

羚羊计划还提供了一组额外的任务提供在分发的标准任务中找不到的功能蚂蚁.将 Antelope 任务与 AntContrib 合并的工作正在进行中项目.
[...]
Ant-Contrib 项目是任务的集合(有时可能是类型和其他工具)用于 Apache Ant.一些Antelope 任务现在是该项目的一部分.

但不知何故,那些合并计划停滞不前并且从未正确完成,Antcontrib 似乎也死了 - 2006 年 11 月 2 日的最新版本 1.0b3

无论如何,您可以将 ant 匹配条件与 antcontrib 一起使用:

<!-- 导入 AntContrib --><taskdef resource="net/sf/antcontrib/antlib.xml"/><property name="foo" value="D:\FeiLong Soft\Essential\Development\repository\org\springframework\spring-beans"/><如果><matches string="${foo}" pattern="^.+spring-beans$"/><然后><echo>等于</echo></然后><其他><echo>不等于</echo></else></如果></项目>

羚羊蚂蚁任务.>

the ant-contrib lastest version is ant-contrib-1.0b3.jar?

http://ant-contrib.sourceforge.net/tasks/tasks/more_conditions.html

this document show endsWith condition

But I use ant 1.8.2 And ant-contrib-1.0b3.jar, I cann't find the endsWith condition

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

But result:

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

解决方案

When checking the sources from antcontrib (version 1.0b2 or 1.0b3) especially net/sf/antcontrib/antcontrib.properties and ../antlib.xml you'll see, there is no startsWith or endsWith condition, though it's mentioned in the antcontrib manual.

Those two conditions originate from the Antelope project, which provides a UI for running ant and several ant tasks. Years ago there were plans to merge Antelope with AntContrib, see Antelope Tasks Merging with AntContrib and Antelope project site :

The Antelope Project also provides a set of additional tasks that provide functionality not found in the standard tasks distributed with Ant. Work is underway to merge the Antelope tasks with the AntContrib project.
[...]
The Ant-Contrib project is a collection of tasks (and at one point maybe types and other tools) for Apache Ant. Some of the Antelope tasks are now part of that project.

But somehow those merging plans stagnated and never finished properly, also Antcontrib seems to be dead - latest release 1.0b3 from 2006-11-02

Anyway, you may either use the ant matches condition with 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>

or the Antelope ant tasks.

这篇关于使用ant-contrib,如何使用“endsWith"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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