Reputation: 2006
How can I synchronize two directories after task execution? I can do it like this:
task syncDirs(type: Sync) {
...
}
task someTask {
doLast {
syncDirs.execute()
}
}
But method "execute" is internal and I have to avoid it.
Thanks for the answer in advance.
Upvotes: 1
Views: 1886
Reputation: 1620
task myTask << {
copy {
from 'src_dir'
into 'dst_dir'
include 'myfile.txt'
}
sync {
from "src_dir/foo"
into "dst_dir/bar"
}
}
In Gradle 1.10, you can do things like copy files and sync dirs all in a single task. I prefer this to having separate tasks for copying and syncing.
For syncing, the idea of doing a separate delete and copy, as suggested above, seems tedious. I'm glad I can call sync
to do both.
Upvotes: 1
Reputation: 123960
Depending on your exact needs, you can use syncDirs.dependsOn(someTask)
, or call the delete
and copy
methods inside someTask.doLast
(that's how Sync
is currently implemented).
Upvotes: 1