I’m trying to write a timestamp as a context parameter into my context.xml at that time I execute my Ant script.
I was trying the following:
my context.xml
<Parameter name="deployingTimeStamp"
value="16.07.2012" <!-- shall be changed! -->
override="true" />
my build.xml
<tstamp>
<format property="time" pattern="dd.MM.yyyy"
unit="hour"/>
</tstamp>
<replace file="${conf.dir}/dev/context.xml" >
<replacefilter token="deployingTimeStamp" value="${time}" />
</replace>
Unfortunately it doesn’t replace the value, it just replaces the name “deployingTimeStamp” itself and changes it to the current date.
How can I solve this problem?
The replacefilter token is going to replace the token you define. Why don’t you add a placeholder value in the XML (i.e. [[buildTimeStamp]] ) and then use:
So your original xml would be
Additional tips based on comment discussion:
What you might not be doing is copying your main source files into a build directory to perform your replaces first. This is pretty standard in build scripts which is why I mentioned you check your files out of source control first. If you are not using source control and have a folder on your computer then you need to copy the files from that folder to another folder first before performing your replace and other packaging of the app.
Something like above where you copy source to working directory. THEN you perform your actions on it, and afterwards remove it when you have a package (i.e. jar file or war file or something if java). You can view the delete functionality in Ant’s documentation as well: