Linux folder sticky-bit reset in build folder

I run Gradle on a Linux box, where it runs in a workspace with special group permissions; the sticky bit is set for the group on the workspace folder.

So all folders created by Gradle should inherit the same settings. This worked well with the (now ancient) 1.0-milestone-3, example:

+ ls -la build/resources/main/folder
total 12
drwxrwsr-x 3 buildserverworker g_bs_current 4096 Sep
5 10:49 .
drwxrwsr-x 3 buildserverworker g_bs_current 4096 Sep
5 10:49 ..
-rw-rw-r-- 1 buildserverworker g_bs_current
  0 Sep
5 09:41 file.txt
drwxrwsr-x 2 buildserverworker g_bs_current 4096 Sep
5 10:49 folder2

But in 1.0-milestone-9 this was apparently broken. Probably due to the “Copy and archive tasks preserve file permissions on UNIX” change.

The output from this release (and 1.7) is:

+ ls -la build/resources/main/folder
total 12
drwxrwxr-x 3 buildserverworker g_bs_current
    4096 Sep
5 10:53 .
drwxrwsr-x 3 buildserverworker g_bs_current
    4096 Sep
5 10:53 ..
-rw-rw-r-- 1 buildserverworker buildserverworker
  0 Sep
5 10:53 file.txt
drwxrwxr-x 2 buildserverworker buildserverworker 4096 Sep
5 10:53 folder2

Notice how the g+s mode of folder2 is lost, and the file.txt and folder2 have different group owners.

I have made a small project with a shell helper that displays the problem when run with different Gradle versions.