I have created a zip file using OpenJDK 11 and Apache Commons Compress 1.20 which is returned by an API using a Netty server. This zip file contains a gradle wrapper that has executable file permissions (755).
-rwxr-xr-x 1 myuser mygroup 5766 Aug 24 16:03 gradlew
I zip it with Commons Compress, return it in the API response, and the browser saves the zip to disk.
If I extract the zip file in MacOS Mojave the gradle wrapper file looks like this (with extended file attributes listing):
ls -al@ gradlew
-rwxr-xr-x@ 1 myuser mygroup 5766 Nov 30 1979 gradlew
com.apple.quarantine 56
Ok, it's quarantined, but still executable. It works fine to execute it.
If I extract the zip file in MacOS Catalina the gradle wrapper file looks like this (with extended file attributes listing):
ls -al@ gradlew
-rw-rw-r--@ 1 myuser mygroup 5766 Nov 30 1979 gradlew
com.apple.quarantine 57
The executable file permissions have been removed by Catalina. Is there some way to circumvent this, except by adding the executable file permissions after unzipping?
I've come across similar issue recently and found the solution at Spring Initializr source code
In short, the solution is to modify permissions of gradlew archive entry to make it executable after unarchiving.
Here is an example of code I used, it is on Kotlin but can be easily converted into Java if required.