How Do I Remove A File From An Archive Using Gradl

2019-05-16 11:25发布

问题:

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.

回答1:

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