Compile task preserves file permissions which may cause builds to fail

Issue #15 resolved
Dave Ray
created an issue

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.


Total time: 4.532 secs

Comments (5)

  1. Meikel Brandmeyer

    My sins are coming back to haunt me. But bear with me! I was young and needed the build.

    The real solution is to not copy the files at all. I think it would be best to configure the outputs of the task after the project is evaluated and we know whether to AOT compile, or not.

    I'm not sure whether this works. And there is probably still the issue that a project could modify the subproject's compile settings after it is evaluated.

    I will check.

  2. Meikel Brandmeyer

    I finally went with the mode setting. By default it preserves file modes. But the compile task has now corresponding file mode settings.

    compileClojure {
        dirMode  = 755
        fileMode = 644

    Please re-open if this is not enough.

  3. Log in to comment