Gradle's distZip
task creates a zip with the following structure
MyApp.zip
`-- MyApp
|-- bin
| |-- ...
`-- lib
|-- ...
how to skip the parent directory and just zip the files like below
MyApp.zip
|-- bin
| |-- ...
`-- lib
|-- ...
It's not possible by default, but it is possible to travrse all the files, which will be included into the final zip and modify it's destination path in this zip, as:
distZip {
eachFile { file ->
String path = file.relativePath
file.setPath(path.substring(path.indexOf("/")+1,path.length()))
}
}
Here is the additional distZip
task's configuration added, which modifies each file's destination path within the final zip-archive, deleting the root folder from it. In your case, it will delete the MyApp
folder from the zip.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With