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

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

问题描述

我试图更新使用Ant WAR任务的现有WAR文件中的文件。
我需要从我的硬盘新的来代替一组XML文件的文件夹在WAR。

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>

这如果原来战争不会有同名XML的正常工作。然而,如果原来的WAR包含具有相同名称的XML的; 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.

该ANT WAR文件的任务内容如下:

The ANT WAR task documentation reads:

更新|指示是否更新或覆盖目标文件,如果它已经存在。默认为假。结果
  复制|当重复的文件中找到的行为。有效值是增加,preserve和​​不合格。默认值是增加。

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.

因此​​未产生任何效果无论是。

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

这是怎么实现这一点?任何建议

Any suggestions on how this can be achieved??

推荐答案

似乎与更新= TRUE 选项,战争文件比你想要的文件更新更新。 有人建议适用触摸任务与0要解决这个问题

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更近。一种解决方法将是&LT;触摸米利斯=0/方式&gt; 前加入压缩文件

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.

或者你可以做的<一个href=\"http://mail-archives.apache.org/mod_mbox/ant-user/200207.mbox/%3C003d01c22ff5%245a093100%240200a8c0@octovma%3E\">reverse东西:

执行触摸之前XML文件(S)的任务使它
  的工作。

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

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

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