api / org.gradle.api.tasks / Sync

Sync

open class Sync : AbstractCopyTask

Synchronizes the contents of a destination directory with some source directories and files.

This task 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(Action) is specified.

Examples:

 // Sync can be used like a Copy task // See the Copy documentation for more examples task syncDependencies(type: Sync) { from 'my/shared/dependencyDir' into 'build/deps/compile' } // You can preserve output that already exists in the // destination directory. Files matching the preserve // filter will not be deleted. task sync(type: Sync) { from 'source' into 'dest' preserve { include 'extraDir/**' include 'dir1/**' exclude 'dir1/extra.txt' } } 

Constructors

<init>

Sync()

Synchronizes the contents of a destination directory with some source directories and files.

This task 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(Action) is specified.

Examples:

 // Sync can be used like a Copy task // See the Copy documentation for more examples task syncDependencies(type: Sync) { from 'my/shared/dependencyDir' into 'build/deps/compile' } // You can preserve output that already exists in the // destination directory. Files matching the preserve // filter will not be deleted. task sync(type: Sync) { from 'source' into 'dest' preserve { include 'extraDir/**' include 'dir1/**' exclude 'dir1/extra.txt' } } 

Functions

getDestinationDir

open fun getDestinationDir(): File

Returns the directory to copy files into.

getPreserve

open fun getPreserve(): PatternFilterable

Returns the filter that defines which files to preserve in the destination directory.

getRootSpec

open fun getRootSpec(): DestinationRootCopySpec

preserve

open fun preserve(action: Action<in PatternFilterable>): Sync

Configures the filter that defines which files to preserve in the destination directory.

setDestinationDir

open fun setDestinationDir(destinationDir: File): Unit

Sets the directory to copy files into. This is the same as calling #into(Object) on this task.

Inherited Functions

eachFile

open fun eachFile(action: Action<in FileCopyDetails>): AbstractCopyTask
open fun eachFile(closure: Closure<Any>): AbstractCopyTask

{@inheritDoc}

exclude

open fun exclude(vararg excludes: String): AbstractCopyTask
open fun exclude(excludes: MutableIterable<String>): AbstractCopyTask
open fun exclude(excludeSpec: Spec<FileTreeElement>): AbstractCopyTask
open fun exclude(excludeSpec: Closure<Any>): AbstractCopyTask

{@inheritDoc}

expand

open fun expand(properties: MutableMap<String, *>): AbstractCopyTask

{@inheritDoc}

filesMatching

open fun filesMatching(pattern: String, action: Action<in FileCopyDetails>): AbstractCopyTask
open fun filesMatching(patterns: MutableIterable<String>, action: Action<in FileCopyDetails>): AbstractCopyTask

{@inheritDoc}

filesNotMatching

open fun filesNotMatching(pattern: String, action: Action<in FileCopyDetails>): AbstractCopyTask
open fun filesNotMatching(patterns: MutableIterable<String>, action: Action<in FileCopyDetails>): AbstractCopyTask

{@inheritDoc}

filter

open fun filter(properties: MutableMap<String, *>, filterType: Class<out FilterReader>): AbstractCopyTask
open fun filter(filterType: Class<out FilterReader>): AbstractCopyTask
open fun filter(closure: Closure<Any>): AbstractCopyTask
open fun filter(transformer: Transformer<String, String>): AbstractCopyTask

{@inheritDoc}

from

open fun from(vararg sourcePaths: Any): AbstractCopyTask
open fun from(sourcePath: Any, c: Closure<Any>): AbstractCopyTask
open fun from(sourcePath: Any, configureAction: Action<in CopySpec>): AbstractCopyTask

{@inheritDoc}

getDirMode

open fun getDirMode(): Int

{@inheritDoc}

getDuplicatesStrategy

open fun getDuplicatesStrategy(): DuplicatesStrategy

{@inheritDoc}

getExcludes

open fun getExcludes(): MutableSet<String>

{@inheritDoc}

getFileMode

open fun getFileMode(): Int

{@inheritDoc}

getFilteringCharset

open fun getFilteringCharset(): String

{@inheritDoc}

getIncludeEmptyDirs

open fun getIncludeEmptyDirs(): Boolean

{@inheritDoc}

getIncludes

open fun getIncludes(): MutableSet<String>

{@inheritDoc}

getSource

open fun getSource(): FileCollection

Returns the source files for this task.

include

open fun include(vararg includes: String): AbstractCopyTask
open fun include(includes: MutableIterable<String>): AbstractCopyTask
open fun include(includeSpec: Spec<FileTreeElement>): AbstractCopyTask
open fun include(includeSpec: Closure<Any>): AbstractCopyTask

{@inheritDoc}

into

open fun into(destDir: Any): AbstractCopyTask
open fun into(destPath: Any, configureClosure: Closure<Any>): AbstractCopyTask
open fun into(destPath: Any, copySpec: Action<in CopySpec>): CopySpec

{@inheritDoc}

isCaseSensitive

open fun isCaseSensitive(): Boolean

{@inheritDoc}

rename

open fun rename(closure: Closure<Any>): AbstractCopyTask
open fun rename(renamer: Transformer<String, String>): AbstractCopyTask
open fun rename(sourceRegEx: String, replaceWith: String): AbstractCopyTask
open fun rename(sourceRegEx: Pattern, replaceWith: String): AbstractCopyTask

{@inheritDoc}

setCaseSensitive

open fun setCaseSensitive(caseSensitive: Boolean): Unit

{@inheritDoc}

setDirMode

open fun setDirMode(mode: Int): AbstractCopyTask

{@inheritDoc}

setDuplicatesStrategy

open fun setDuplicatesStrategy(strategy: DuplicatesStrategy): Unit

{@inheritDoc}

setExcludes

open fun setExcludes(excludes: MutableIterable<String>): AbstractCopyTask

{@inheritDoc}

setFileMode

open fun setFileMode(mode: Int): AbstractCopyTask

{@inheritDoc}

setFilteringCharset

open fun setFilteringCharset(charset: String): Unit

{@inheritDoc}

setIncludeEmptyDirs

open fun setIncludeEmptyDirs(includeEmptyDirs: Boolean): Unit

{@inheritDoc}

setIncludes

open fun setIncludes(includes: MutableIterable<String>): AbstractCopyTask

{@inheritDoc}

with

open fun with(vararg sourceSpecs: CopySpec): CopySpec

{@inheritDoc}