Compile task preserves file permissions which may cause builds to fail
We use perforce (yes, it's sad) which marks all files as read-only at checkout. These file permissions are currently preserved by the compile task that copies clojure files to
build/classes. This can cause future builds to fail with write errors. See below for steps to reproduce.
Our local gradle guru suggests taking a look at
org.gradle.language.jvm.tasks.ProcessResources rather than
project.copy because it deletes everything from the target before copying which would avoid these issues.
Steps to reproduce:
$ cd kotarak-lazymap-bb62d17771fa/ ... make the file read-only, simulating recent perforce checkout :( $ chmod 444 src/main/clojure/lazymap/core.clj $ ./gradlew build ... build succeeds ... ... make the file writable again ... $ chmod 644 src/main/clojure/lazymap/core.clj ... make some minor change to the file $ ./gradlew build :compileClojure FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileClojure'. > Could not copy file '/Users/dray/tmp/lazymap/kotarak-lazymap-bb62d17771fa/src/main/clojure/lazymap/core.clj' to '/Users/dray/tmp/lazymap/kotarak-lazymap-bb62d17771fa/build/classes/main/lazymap/core.clj'. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 4.532 secs