Process*Resources fails on rebuild if resources are read-only on Mac

processResources and processTestResources is failing during rebuilds if a resource is updated, it is read-only, and it is running on a Mac.

We do not see this problem on Windows (our primary user base). Our SCM is Perforce, so all files that are not actively being worked on (‘opened for add or edit’, in Perforce terminology) are generally set to read-only in the src folder.

We have experienced similar problems with ZipTree. We have encoded workarounds to remove the ‘expandedArchives’ folders at the start of each build. Gradle put the original files there, and when Gradle needs to overwrite them it ought to be able to do that without having to encode build-script workarounds to make it happen.

I can imagine some possible workarounds -

  • Is there some global flag that can be set so that files written by Gradle in the build tree will be overwritable?
  • Do I need to search all projects for Copy tasks and set the fileMode when running on Mac?
  • Should I create a prebuild step that marks all files as writable in the build tree?

I’m entering this in ‘bugs’ rather than ‘Help’ because it seems Gradle should be able to handle this case without requiring workarounds. (The workarounds are not necessary on Windows.) If it determines a read-only build output file is out of date and needs to be replaced, it should delete it before it tries to overwrite it, if the OS will not permit it to overwrite it directly - that ought to be completely transparent to the user.

1 Like