更新现有 WAR 文件中的文件 [英] Updating files inside an existing WAR file

查看:30
本文介绍了更新现有 WAR 文件中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 ANT WAR 任务更新现有 WAR 文件中的文件.我需要用我的硬盘中的新文件替换 WAR 文件夹中的一组 xml 文件.

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>

如果原始 WAR 没有同名的 xml,这可以正常工作.但是,如果原始 WAR 包含同名的 xml;WAR 任务不会使用 HDD 中的文件更新它们.

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.

ANT WAR 任务文档如下:

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".

如果我使用 update="false";原始 WAR 中的所有其他文件都被删除,只存储新的 xml.

if i use update="false"; all other files in the original WAR are deleted and only the new xmls stored.

使用 duplicate="add" 也没有任何效果.

using duplicate="add" didnot have any effect either.

关于如何实现这一目标的任何建议??

Any suggestions on how this can be achieved??

推荐答案

似乎使用 update=true 选项,war 文件比您要更新的文件新.有人建议应用带有0"的 touch 任务来解决该问题.

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.

zip 任务仅检查您希望添加到现有 zip 的源文件是否比 zip 更新.一种解决方法是在添加之前<touch millis="0"/> zip 文件.

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.

或者你可以做 相反的东西:

在 XML 文件的 war 任务之前执行 touch工作.

Performing a touch before the war task on XML file(s) makes it work.

这篇关于更新现有 WAR 文件中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆