2009-07-22 32 views

回答

2

屬性是映射而不是列表。您可以使用property task從文件中讀取一組屬性。

例如:

<property file="${dir}/external.properties"/> 

該屬性文件具有如在類java.util.Properties使用的文件有關如何非ISO8859-1字符必須定義,具有相同的規則的格式逃脫。

當讀取屬性文件時,它允許展開文件中的屬性。一旦文件被讀取,它們將被正常訪問。所以,如果external.properties包含:

test.dir=/usr/test 
test.file=foo 
test.target=${test.dir}/${test.file}/ 

你可以在你的任務直接引用test.target:

<!-- Will create the directory structure /usr/test/foo --> 
<mkdir dir="${test.target}"/> 
+0

呀,但你不能做的mkdir當你指向一個文件名...或者至少,你不應該。 – djangofan 2011-08-23 17:17:35

1

請參閱Property

<property file="foo.properties"/>