api / org.gradle.api.file / CopySourceSpec

CopySourceSpec

interface CopySourceSpec

Specifies sources for a file copy.

Functions

from

abstract fun from(vararg sourcePaths: Any): CopySourceSpec

Specifies source files or directories for a copy. The given paths are evaluated as per .

abstract fun from(sourcePath: Any, configureClosure: Closure<Any>): CopySourceSpec

Specifies the source files or directories for a copy and creates a child CopySourceSpec. The given source path is evaluated as per org.gradle.api.Project#files(Object...) .

abstract fun from(sourcePath: Any, configureAction: Action<in CopySpec>): CopySourceSpec

Specifies the source files or directories for a copy and creates a child CopySpec. The given source path is evaluated as per org.gradle.api.Project#files(Object...) .

Inheritors

CopySpec

interface CopySpec : CopySourceSpec, CopyProcessingSpec, PatternFilterable

A set of specifications for copying files. This includes:

  • source directories (multiples allowed)
  • destination directory
  • ANT like include patterns
  • ANT like exclude patterns
  • File relocating rules
  • renaming rules
  • content filters
CopySpecs may be nested by passing a closure to one of the from methods. The closure creates a child CopySpec and delegates methods in the closure to the child. Child CopySpecs inherit any values specified in the parent. This allows constructs like:
 def myCopySpec = project.copySpec { into('webroot') exclude('**/.data/**') from('src/main/webapp') { include '**/*.jsp' } from('src/main/js') { include '**/*.js' } } 
In this example, the into and exclude specifications at the root level are inherited by the two child CopySpecs. Copy specs can be reused in other copy specs via #with(CopySpec...) method. This enables reuse of the copy spec instances.
 def contentSpec = copySpec { from("content") { include "**/*.txt" } } task copy(type: Copy) { into "$buildDir/copy" with contentSpec }