Copy task UP-TO-DATE unreliable

I have a multi-project setup and am adding some tasks to projects with a custom plugin. Here’s a shortened version of the plugin adding the copyResources task.

class CopyTasks implements Plugin<Project> {
    void apply(Project project) {
        project.task("copyResources", type: Copy) {
//
          outputs.upToDateWhen {false}
            from "${project.resourcesDir}"
            into "${project.distDir}"
            fileMode = 0644
        }
    }
}

In my root project build.gradle, I’m defining resourcesDir and distDir and adding the plugin for all subprojects.

subprojects {
    ext.resourcesDir = "src/main/resources"
    ext.distDir = "$buildDir/dist"
      apply plugin: CopyTasks
}

When I have the ‘outputs.upToDateWhen {false}’ line commented out, the task is sometimes considered UP-TO-DATE and not executed, even when I’m telling gradle to clean first. Other times it DOES execute the task with the line commented out. However, I haven’t been able to reproduce the problem when the outputs.upToDateWhen {false} line is added, yet. I wish I had more specific data about the scenario causing the problem, but I can’t even always reproduce the issue myself. Also, this isn’t the only Copy task that is sometimes considered UP-TO-DATE after a clean, but it’s a good example. I’ve experienced the problem with versions 1.4 and 1.5.

Are there known issues with the Copy tasks requiring the upToDateWhen trick to run in versions 1.4 and 1.5? Any idea why I would be experiencing unreliable results? Just hoping to get some thoughts or ideas about what could be going on.

There are no known issues of this intermittent nature.

There are some issues about certain Copy task configuration options (e.g. renaming) that don’t invalidate outputs when they change, but nothing like what you are talking about.

If it’s happening to other tasks as well, I’d hazard a guess that something is quite wrong with your build or environment.

There’s not much I can think of without it being reproducible.