Java 蚂蚁目标不';t覆盖现有的xml文件
我正在处理一个ant脚本,我的ant目标解压缩war文件,然后重命名/替换该文件并再次压缩war文件。因此,我的war文件的结构是WEB-INF文件夹,其中包含WEB-muqmreports.xml和WEB.xml文件 我的目标解压war文件,然后制作web-muqmreports.xml的副本 使用名称web.xml,将其放回war文件,然后将其压缩,但问题是我在web-INF文件夹中已经有一个web.xml文件,因此当目标将重命名的web.xml文件放在web-INF文件夹中时,它不会覆盖现有的web.xml文件 我的目标很好。我检查了一下,没有用web.xml重命名文件名。我用web_tt.xml重命名了它,之后我可以看到war中的文件 有人能告诉我为什么它没有覆盖现有的web.xml文件吗 是否有任何方法可以在以下目标中的zip之前删除现有的web.xml文件Java 蚂蚁目标不';t覆盖现有的xml文件,java,ant,Java,Ant,我正在处理一个ant脚本,我的ant目标解压缩war文件,然后重命名/替换该文件并再次压缩war文件。因此,我的war文件的结构是WEB-INF文件夹,其中包含WEB-muqmreports.xml和WEB.xml文件 我的目标解压war文件,然后制作web-muqmreports.xml的副本 使用名称web.xml,将其放回war文件,然后将其压缩,但问题是我在web-INF文件夹中已经有一个web.xml文件,因此当目标将重命名的web.xml文件放在web-INF文件夹中时,它不会覆盖现
<target name="env.replace.webxml">
<echo message="Replacing app web.xml"/>
<move todir="${deploy.war.dir}">
<fileset dir="${deploy.war.dir}" includes="*.war" />
<regexpmapper from=".*\.war" to="${deploy.appname}.war" />
</move>
<delete dir="WEB-INF"/>
<unzip src="${deploy.war.dir}/${deploy.appname}.war" dest=".">
<patternset>
<include name="WEB-INF/${deploy.use.web.xml}"/>
</patternset>
<globmapper from="WEB-INF/${deploy.use.web.xml}" to="WEB-INF/web.xml"/>
</unzip>
<zip destfile="${deploy.war.dir}/${deploy.appname}.war" basedir="." includes="WEB-INF/web.xml" update="true"/>
</target>
我解决了这个问题,在ant目标中又添加了一个步骤
<target name="env.replace.webxml">
<echo message="Replacing app web.xml"/>
<move todir="${deploy.war.dir}">
<fileset dir="${deploy.war.dir}" includes="*.war" />
<regexpmapper from=".*\.war" to="${deploy.appname}.war" />
</move>
<delete dir="WEB-INF"/>
<unzip src="${deploy.war.dir}/${deploy.appname}.war" dest=".">
<patternset>
<include name="WEB-INF/${deploy.use.web.xml}"/>
</patternset>
<globmapper from="WEB-INF/${deploy.use.web.xml}" to="WEB-INF/web.xml"/>
</unzip>
**<tstamp> <format property="touch.time" pattern="MM/dd/yyyy hh:mm aa"/> </tstamp>
<touch datetime="${touch.time}">
<fileset dir="." />
</touch>**
<zip destfile="${deploy.war.dir}/${deploy.appname}.war" basedir="." includes="WEB-INF/web.xml" update="true"/>
</target>
**
**
我也有类似的问题。我有包括web.xml在内的自定义文件,我需要在已经构建的war中更新这些文件。关键的是触摸我想放在war中的文件夹中的文件。示例如下:
<target>
<tstamp>
<format property="touch.time" pattern="MM/dd/yyyy hh:mm:ss"/>
</tstamp>
<touch datetime="${touch.time}" pattern="MM/dd/yyyy hh:mm:ss">
<fileset dir="${project.build.directory}/${war-update-dir}" />
</touch>
<war destfile="${final.war}" update="true" needxmlfile="false">
<zipfileset dir="${project.build.directory}/${war-update-dir}" prefix=""/>
</war>
<delete dir="${project.build.directory}/${war-update-dir}"/>
</target>
使用verbose选项(Ant-v target)运行Ant,并将输出包含在问题中。该输出应该解释为什么Ant没有替换您的文件。我可以添加步骤删除war文件中已经存在的web.xml文件,然后将其压缩到Ant目标上。如果是,请告诉我如何执行此操作