2011-02-03 166 views
0

使用Apache Ant 1.7.1蚂蚁filterset任务不递归

它看起来像蚂蚁筛选任务时递归设置为true不能多次解决同一个属性的一条线。我在Ant文档中找不到任何提及。这是否应该发生?

使用这种蚂蚁构建文件:

<project basedir="." default="assemble" > 
    <macrodef name="copy-and-filter"> 
    <sequential> 
     <copy tofile="to.txt" file="from.txt" overwrite="true"> 
     <filterset recurse="true"> 
      <filtersfile file="filters.properties"/> 
     </filterset> 
     </copy> 
    </sequential> 
    </macrodef> 

    <target name="assemble"> 
    <copy-and-filter /> 
    </target> 
</project> 

这些文件:

from.txt:

I want my broker to be: @[email protected] 
and my client to be: @[email protected] 

filters.properties:

myval=fish 
[email protected]@- 
[email protected]@[email protected]@ 

我得到的输出为:

i want my broker to be: -fish- 
and my client to be: myval 

,而不是我所期待这将是这样的:

i want my broker to be: -fish- 
and my client to be: fish-fish 

如果我设置递归为false然后我得到了“正确”的行为。

i want my broker to be: [email protected]@- 
and my client to be: @[email protected]@[email protected] 

这是为什么?

+0

该代码适用于您想要的更高版本的Ant。这里有一个Ant错误:https://issues.apache.org/bugzilla/show_bug.cgi?id = 44226它似乎在1.8.0和1.81固定。 – 2011-02-03 14:14:50

回答

0

在初始替换发生后,递归标志旨在寻找更多的标记,但如果再次使用相同的标记,它将不起作用。问题是设置recurse = true会导致无限循环。看到输出从蚂蚁:

Infinite loop in tokens. Currently known token tokens: [client.url, myval] 
Problem token: @[email protected] called from @[email protected] 

我不认为它可以做你希望能够使用filterset任务做什么。你用to.txt文件做什么?它是提供一个系统配置文件吗?

+0

是的,我的IDE隐藏了这个错误。 我不得不重新考虑我在这里做什么。 – 2011-02-03 14:10:42