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

前端 未结 2 696
半阙折子戏
半阙折子戏 2021-01-13 23:08

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

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

this document show

相关标签:
2条回答
  • 2021-01-13 23:33

    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>
    
    0 讨论(0)
  • 2021-01-13 23:55

    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.

    0 讨论(0)
提交回复
热议问题