Gradle: Sync task considers project up-to-date even though files are added to destination dir

Viewed 2119

I'm using this simple Gradle task:

task syncTask(type: Sync) {
    from "src/"
    into "dest/"
}

According to the docs, I'm expecting that src is copied to dest and that any files not present in src are removed from dest. This basically works fine. However, if there are files added to dest after syncing, this is not recognized when the task runs again. The project is simply considered UP-TO-DATE and no action is taken.

Is it possible to configure the Sync task so that added files in the destination directory are detected and the task is run again?

> gradle -v

------------------------------------------------------------
Gradle 1.9
------------------------------------------------------------

Build time:   2013-11-19 08:20:02 UTC
Build number: none
Revision:     7970ec3503b4f5767ee1c1c69f8b4186c4763e3d

Groovy:       1.8.6
Ant:          Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:          2.2.0
JVM:          1.7.0_25 (Oracle Corporation 23.7-b01)
OS:           Linux 3.2.0-53-generic amd64

Edit 1: Here are the steps to reproduce the behaviour:

$ mkdir src
$ touch src/a
$ mkdir dest
$ gradle syncTask
:syncTask

BUILD SUCCESSFUL

Total time: 1.113 secs
$ ls dest/
a

So far, everything works as expected. Now, a file b is added to the dest/ folder:

$ touch dest/b
$ ls dest/
a  b
$ gradle syncTask
:syncTask UP-TO-DATE

BUILD SUCCESSFUL

Total time: 1.024 secs

I would expect that b is removed from dest/. However, the Sync task doesn't seem to notice that its outputs have changed and thus doesn't run.

2 Answers
Related