为了让您的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