ant : jar 和 zipfileset

编程入门 行业动态 更新时间:2024-10-28 20:30:16
本文介绍了ant : jar 和 zipfileset - 将文件从一个 JAR 复制到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我目前正在这样做:

<jar update="yes"
     jarfile="${pwd}/dist/${release}_installer.jar">
   <zipfileset src="${pwd}/dist/app.jar" includes="com/izforge/izpack/panels/**"/>
   <zipfileset src="${pwd}/dist/app.jar" includes="com/xyz/img/logo.png"/>
</jar>

我现有的安装程序 JAR 得到更新,以根据需要包含从应用 JAR 中提取的文件.

My existing installer JAR gets updated to include the files as needed, extracted from the app JAR.

到目前为止,一切都很好.

So far, so good.

但是,我想修改行为,使图像文件的路径与从中复制的路径不同:

However, I want to modify the behaviour such that the path of the image file is different than what is being copied from:

目前:

com/izforge/izpack/panels/MyIzPanel.class
com/xyz/img/logo.png

我想要的:

com/izforge/izpack/panels/MyIzPanel.class
blah/img/logo.png

所以我需要复制文件,但使用 这样我就可以修改目录结构了.

So I need to copy the files, but use <zipfileset> and <jar> in such a way that I can modify the directory structure.

有没有办法做到这一点,除了解压缩整个内容复制文件然后再次压缩它?

Is there a way to do this, apart from unzipping the entire contents copying file and then zipping it back up again?

链接到较早的相关问题:ant task to remove files from a罐子

Link to earlier related question: ant task to remove files from a jar

推荐答案

您可以使用 fullpath 属性:

<zipfileset src="${pwd}/dist/app.jar"
    includes="com/xyz/img/logo.png" fullpath="blah/img/logo.img"/>

如果您需要复制多个文件,您可能需要查看 prefix 属性,例如:

If you need to copy several files you may want to have a look at the prefix attribute, e.g.:

<zipfileset src="${pwd}/dist/app.jar"
    includes="**/*.png" prefix="blah/img"/>

这篇关于ant : jar 和 zipfileset - 将文件从一个 JAR 复制到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-20 10:49:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/982144.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ant   jar   zipfileset

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!