如何使用'loadfile'任务将文件加载到ant中的变量中?

lee*_*d00 9 ant ant-loadfile

我正在尝试以下内容,似乎无法正常工作.

<property name="file.configs.txt" value="" />
...
<target name="...">
   <loadfile property="file.configs.txt" srcFile="remoteConfig/configs.txt" />
</target>
Run Code Online (Sandbox Code Playgroud)

在这里读到<loadfile>任务应该将文件的内容加载到指定的属性中.

set*_*eth 13

摆脱属性定义线. 属性是不可变的.

 <project name="foobar" default="foo">
   <target name="foo">
     <loadfile property="foo.bar" srcFile="foobar/moo.txt"/>
     <echo>${foo.bar}</echo>
   </target>
 </project>
Run Code Online (Sandbox Code Playgroud)


Nat*_*ate 11

属性在Ant中是不可变的.file.configs.txt的第一个定义将阻止再次设置它.

来自:http://ant.apache.org/manual/Tasks/property.html

属性是不可变的:任何设置属性的人都会将其冻结为其余的构建; 他们绝对不是变数.