我正在尝试使用ANT WAR任务更新现有WAR文件中的文件.我需要用我的硬盘中的新文件替换WAR中文件夹中的一组xml文件.
<war destfile="myApp.war" update="true" >
<zipfileset dir="<PathToStubsFolderOnHDD>" includes="**/*.xml" prefix="<PathToStubsFolderInWAR>"/>
</war>
Run Code Online (Sandbox Code Playgroud)
如果原始WAR没有具有相同名称的xmls,则此方法可以正常工作.但是,如果原始WAR包含具有相同名称的xmls; WAR任务不会使用HDD中的文件更新它们.
ANT WAR任务文档如下:
更新| 指示是否更新或覆盖目标文件(如果已存在).默认为"false".
重复| 找到重复文件时的行为.有效值为"add","preserve"和"fail".默认值为"add".
如果我使用update ="false"; 原始WAR中的所有其他文件都将被删除,并且只存储新的xmls.
使用duplicate ="add"也没有任何效果.
关于如何实现这一点的任何建议?
谢谢Aito!
这是完整的ANT脚本:
<target name = "UpdateWARWithStubs"
description="Updates WAR file with files from Stub folder">
<!-- Use touch to set modification time of all stubs to current time. This will force war task to update stub files inside the war -->
<tstamp> <format property="touch.time" pattern="MM/dd/yyyy hh:mm aa"/> </tstamp>
<touch datetime="${touch.time}">
<fileset dir="${path.to.stubs.on.hdd}" />
</touch>
<war destfile="myApp.war" update="true">
<zipfileset dir="${path.to.stubs.on.hdd}" prefix="${path.to.stubs.in.war}"/>
</war>
</target>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24578 次 |
| 最近记录: |