Use ant-contrib,how to use “endsWith”?

微笑、不失礼 提交于 2019-12-01 08:15:45

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.

I had the same problem using "startwith" and dont found a solution. I don't understood the cause of "contains" working, but "startwith" and "endwith" don't.

<if>
    <contains string="a sample string" substring="sample" />
    <then>
        <echo>match</echo>
    </then>
    <else>
        <echo>not match</echo>
    </else>
</if>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!