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

nah*_*612 3 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>.
Run Code Online (Sandbox Code Playgroud)

它似乎没有第二次加载.但属性文件已更新.

Dan*_*age 6

您可以使用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>
Run Code Online (Sandbox Code Playgroud)

antcall refrence