这是我想要做的,我想在构建期间从我的大量属性文件中替换名称和地址,但不幸的是我不能这样做,有没有更好的方法来做到这一点而不必复制粘贴 foreach 两次。有人可以帮忙吗?
<target name="replace" >
<foreach target="replace.name,replace.address" param="foreach.file" inheritall="true">
<path>
<fileset dir="${build.tmp.dir}/resource">
<!-- some complicated conditions go here -->
</path>
</foreach>
</target>
<target name="replace.address">
<echo>replacing #Address# for ${foreach.file}</echo>
<replace file="${foreach.file}" token="#Address#" value="${address}" />
</target>
<target name="replace.name">
<echo>replacing #Name# for ${foreach.file}</echo>
<replace file="${foreach.file}" token="#Name#" value="${Name}" />
</target>
.properties 文件看起来像
name=#Name#
address=#Address#