# sync

abstract fun sync(action: Action<in SyncSpec>): WorkResult

Synchronizes the contents of a destination directory with some source directories and files. The given action is used to configure a SyncSpec, which is then used to synchronize the files.

This method is like the copy task, except the destination directory will only contain the files copied. All files that exist in the destination directory will be deleted before copying files, unless a preserve option is specified.

Example:

    project.sync {
       from 'my/shared/dependencyDir'
       into 'build/deps/compile'
    }

Content copied to clipboard
Note that you can preserve output that already exists in the destination directory:

    project.sync {
        from 'source'
        into 'dest'
        preserve {
            include 'extraDir/**'
            include 'dir1/**'
            exclude 'dir1/extra.txt'
        }
    }

Content copied to clipboard

#### Return

WorkResult that can be used to check if the sync did any work.

#### Since

4.0

#### Parameters

action

Action to configure the SyncSpec.