Tuesday, January 09, 2007

I had a requirement - I needed to replace the application.xml file inside an EAR file without unpacking the EAR File. Well, ANT came to the rescue ( as sual ) - I used this piece of logic to get it working :-


< target name="modify_ear
>

< touch

file="${src.dir}/application.xml" />

<
ear
destfile="${src.dir}/${ear.name}.ear"

update="true"

appxml="${src.dir}/application.xml"

/>

< /target >



The key here was to "touch" the application.xml file sitting outside the EAR
file. The "touch" changes the TimeStamp of the File & hence, it gets updated
in the EAR File.