I am trying to update files inside an existing WAR file using the ANT WAR task. I need to replace a set of xml files in a folder in WAR with new ones from my HDD.
<war destfile="myApp.war" update="true" >
<zipfileset dir="<PathToStubsFolderOnHDD>" includes="**/*.xml" prefix="<PathToStubsFolderInWAR>"/>
</war>
This works fine if the original WAR does not have xmls with same name. However if the original WAR contains xmls with same name; WAR task does not update them with files from HDD.
The ANT WAR task documentation reads:
update | indicates whether to update or overwrite the destination file if it already exists. Default is "false".
duplicate | behavior when a duplicate file is found. Valid values are "add", "preserve", and "fail". The default value is "add".
if i use update="false"; all other files in the original WAR are deleted and only the new xmls stored.
using duplicate="add" didnot have any effect either.
Any suggestions on how this can be achieved??
Seems that with update=true
option, the war file is newer than the files that you want to update. Someone suggest to apply the touch
task with '0' to workaround the problem.
The zip task checks only if the source files you whish to add to an existing zip are more recent than the zip. A workaround would be to
<touch millis="0" />
the zip file before adding.
Or you could do the reverse stuff:
Performing a
touch
before thewar
task on XML file(s) makes it work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With