ant - 更新属性文件后重新加载属性

标签 ant properties

我正在尝试在使用 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>

antcall refrence

关于ant - 更新属性文件后重新加载属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9098098/

相关文章:

java - 使用ANT根据包名动态生成JAR文件

c# - 为 Func 属性创建 xml 文档的推荐方法是什么

java - 为什么 ivyde 看不到我的依赖项之一?

java - 当一个包从同一项目中的另一个包导入时,我需要使构建失败。我怎样才能干净利落地做到这一点?

java - 如何使用Ant Web Start在build.xml中添加安全权限

ant - 从Gradle设置环境变量

javascript - 从 javascript 属性和值中删除\r

c# - "Tell, don' t 问“: what is the difference between a non-void method and a getter?

c# - C# 中的线程安全属性

iOS MapKit 拖动注释(MKAnnotationView)不再随 map 平移