thenaglecode thenaglecode - 4 years ago 177
Groovy Question

Gradle Sync task, sync into folder but ignore specified directories in destination

I want to synchronize a folder on my drive with another folder that contains a folder named 'logs' that i want to keep. confused? here's a diagram:

C:\
|-- mydir/ # sync this folder
| `-- someotherfiles.txt
`-- anotherDir/ # into this folder
|-- logs/ # but if this exists, leave it there
`-- someotherfiles.txt


Is this possible using the sync task? I can't seem to configure it properly, my latest attempt might allude you to my scenario so here it is (not working):

task syncDevDeployFolder(type: Sync, group: 'dev') {
from currentDeliverablesDir
destinationDir = file(project.properties['dev.deployment.dir'])
into (project.properties['dev.deployment.dir']) {
exclude "logs"
}
}

Answer Source

Is this possible using the sync task?

No, the Sync task doesn't currently support this.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download