我正在尝试在使用 propertyfile 任务更新属性后读取它。像
<property file="test.properties" />
<echo>before :: ${modules}</echo>
<propertyfile file="test.properties" >
<entry key="modules" type="string" operation="+" value="foo" />
</propertyfile>
<property file="${status.path}/test.properties" />
<echo>after :: ${modules}</echo>.
它似乎没有第二次加载。但属性文件已更新。
最佳答案
您可以使用忽略主目标运行时属性的 antcall
任务调用新的 ant 运行时 - 只需确保包含 inheritAll="false"
<target name="main">
<property file="test.properties"/>
<echo>before :: ${modules}</echo>
<propertyfile file="test.properties">
<entry key="modules" type="string" operation="+" value="foo" />
</propertyfile>
<antcall target="second-runtime" inheritAll="false"/>
</target>
<target name="second-runtime">
<property file="${status.path}/test.properties" />
<echo>after :: ${modules}</echo>
</target>
关于ant - 更新属性文件后重新加载属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9098098/