2011-02-03 152 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