如何使用Gradle从档案中删除文件 [英] How Do I Remove A File From An Archive Using Gradle

查看:137
本文介绍了如何使用Gradle从档案中删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Unix中,我可以执行以下操作从我的jar中删除一个文件

  zip -d myfile.jar META-INF /SIGN.RSA 

在Gradle / Groovy中有一种简单的方法吗?



我不想将整个文件解压并重新压缩,因为我有一些非常大的罐子。



可能可以告诉我在用我自己的方式重新签署之前,我会取消签署一些罐子。如果您有解决方案(并且不需要拆包和重新打包),我也会接受您的答案。 解决方案

根据我的知识,这种特定情况没有内置任务。
但是,您可以轻松地使用例如:

  exec {
可执行文件jar.exe
args -d,myfile.jar,META-INF / SIGN.RSA
}


In Unix I can do the following to delete a file from my jar

zip -d myfile.jar META-INF/SIGN.RSA

Is there a simple way to do it in Gradle/Groovy?

I don't want to unzip and re-zip the whole file as I have some very large jars.

As you can probably tell I am un-signing some jars before re-signing them with my own. If you have a solution for that (and doesn't require unpacking and repacking) I'll accept your answer too.

解决方案

Per my knowledge there's no built-in task for this specific case. However, you can easily do it by using exec, e.g.:

exec {
    executable "jar.exe"
    args "-d", "myfile.jar", "META-INF/SIGN.RSA"
}

这篇关于如何使用Gradle从档案中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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