爲了讓您的dirset包括對應的子目錄編輯+覆蓋與腳本任務現有test.property和內置的JavaScript引擎:
<project>
<property name="test.property" value="one,two,three"/>
<echo>1. $${test.property} => ${test.property}</echo>
<script language="javascript">
<![CDATA[
var items = project.getProperty('test.property').split(',');
var s = "";
for (i = 0; i < items.length; i++) {
s += '*' + items[i] + ',';
}
project.setProperty('test.property', s.substring(0, s.length - 1));
]]>
</script>
<echo>2. $${test.property} => ${test.property}</echo>
<dirset id="something" includes="${test.property}" dir="C:\some\path"/>
<echo>Dirset includes => ${toString:something}</echo>
</project>
輸出:
[echo] 1. ${test.property} => one,two,three
[echo] 2. ${test.property} => *one,*two,*three
[echo] Dirset => number.one;number.three;number.two
如果你想創建,而不是覆蓋現有test.property使用一個新的屬性:
project.setProperty('whatever', s.substring(0, s.length - 1));
或
project.setNewProperty('whatever', s.substring(0, s.length - 1));
,並使用新創建的屬性包括您dirset的屬性。
謝謝,這很好。 – daqpan
不客氣。 – aliteralmind
btw。在你的個人資料中年齡= 94似乎是一個錯字! – Rebse