Reputation: 415
By default when you use <loadproperties srcFile="fileDir"/>
the properties are loading in the beginning of ant script execution.
My problem is that the .properties file does not exist in the beginning, as I copy it from other direction(changing it content according to other things). So the question is: can I somehow load .properties file in the middle of ant script dynamically???
Upvotes: 0
Views: 2542
Reputation: 72884
loadproperties
is just a normal Ant task. It is equivalent to multiple calls to the property
task to set properties. You can call it at the beginning of the script, in the middle of a certain target, or anywhere else.
Therefore if the properties file is being dynamically filled during the execution and at some point in target targetX
you'd like to load it, you would just call the task as usual:
<target name="targetX" >
<loadproperties srcfile="${pathToFile}" />
</target>
Note that if you already loaded the properties before (at the very beginning of the Ant script), then the second load will not override property values that have been set in the first call to loadproperties
(since properties are immutable). If you want to override them, you can use the var
task from Ant-Contrib.
Upvotes: 1