# Class SourceTask

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
org.gradle.api.internal.ConventionTask
org.gradle.api.tasks.SourceTask

All Implemented Interfaces:
  `Comparable<Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.IConventionAware, org.gradle.api.internal.TaskInternal, ExtensionAware, Task, PatternFilterable, org.gradle.util.Configurable<Task>`

Direct Known Subclasses:
  `AbstractCompile, AntlrTask, Checkstyle, CodeNarc, CoffeeScriptCompile, FindBugs, Groovydoc, Javadoc, JavaScriptMinify, JsHint, Pmd, RoutesCompile, ScalaDoc, TwirlCompile, UnexportMainSymbol`

public class SourceTask extends org.gradle.api.internal.ConventionTask implements PatternFilterable
A `SourceTask` performs some operation on source files.

## Nested Class Summary

### Nested classes/interfaces inherited from interface Task

`Task.Namer`

## Field Summary

Fields
Modifier and Type
Field
Description
`protected final List<Object>`
`source`

### Fields inherited from interface Task

`TASK_ACTION, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE`

## Constructor Summary

Constructors
Constructor
Description
`SourceTask()`

## Method Summary

Modifier and Type
Method
Description
`SourceTask`
`exclude(Closure excludeSpec)`
Adds an exclude spec.
`SourceTask`
`exclude(Iterable<String> excludes)`
Adds an ANT style exclude pattern.
`SourceTask`
`exclude(String... excludes)`
Adds an ANT style exclude pattern.
`SourceTask`
`exclude(Spec<FileTreeElement> excludeSpec)`
Adds an exclude spec.
`Set<String>`
`getExcludes()`
Returns the set of exclude patterns.
`Set<String>`
`getIncludes()`
Returns the set of include patterns.
`protected org.gradle.internal.Factory<PatternSet>`
`getPatternSetFactory()`
`FileTree`
`getSource()`
Returns the source for this task, after the include and exclude patterns have been applied.
`SourceTask`
`include(Closure includeSpec)`
Adds an include spec.
`SourceTask`
`include(Iterable<String> includes)`
Adds an ANT style include pattern.
`SourceTask`
`include(String... includes)`
Adds an ANT style include pattern.
`SourceTask`
`include(Spec<FileTreeElement> includeSpec)`
Adds an include spec.
`SourceTask`
`setExcludes(Iterable<String> excludes)`
Set the allowable exclude patterns.
`SourceTask`
`setIncludes(Iterable<String> includes)`
Set the allowable include patterns.
`void`
`setSource(Object source)`
Sets the source for this task.
`void`
`setSource(FileTree source)`
Sets the source for this task.
`SourceTask`
`source(Object... sources)`
Adds some source to this task.

### Methods inherited from class org.gradle.api.internal.ConventionTask

`conventionMapping, conventionMapping, getConventionMapping`

### Methods inherited from class DefaultTask

`newInputDirectory, newInputFile, newOutputDirectory, newOutputFile`

### Methods inherited from class org.gradle.api.internal.AbstractTask

`addValidator, appendParallelSafeAction, compareTo, configure, deleteAllActions, dependsOn, dependsOnTaskDidWork, doFirst, doFirst, doFirst, doLast, doLast, doLast, execute, finalizedBy, getActions, getAnt, getAsDynamicObject, getConvention, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExecuter, getExtensions, getFinalizedBy, getGroup, getIdentityPath, getImpliesSubProjects, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOnlyIf, getOutputs, getPath, getProject, getServices, getShouldRunAfter, getStandardOutputCapture, getState, getTaskActions, getTaskDependencies, getTemporaryDir, getTemporaryDirFactory, getValidators, hasProperty, injectIntoNewInstance, isEnabled, isHasCustomActions, leftShift, mustRunAfter, onlyIf, onlyIf, prependParallelSafeAction, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setExecuter, setFinalizedBy, setGroup, setImpliesSubProjects, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, toString`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### source

protected final List<Object> source

## Constructor Details

### SourceTask

public SourceTask()

## Method Details

### getPatternSetFactory

@Inject protected org.gradle.internal.Factory<PatternSet> getPatternSetFactory()

### getSource

@InputFiles @SkipWhenEmpty public FileTree getSource()
Returns the source for this task, after the include and exclude patterns have been applied. Ignores source files which do not exist.

Returns:
  The source.

### setSource

public void setSource(FileTree source)
Sets the source for this task.

Parameters:
  `source` - The source.
Since:
  4.0

### setSource

public void setSource(Object source)
Sets the source for this task. The given source object is evaluated as per `Project.files(Object...)`.

Parameters:
  `source` - The source.

### source

public SourceTask source(Object... sources)
Adds some source to this task. The given source objects will be evaluated as per `Project.files(Object...)`.

Parameters:
  `sources` - The source to add
Returns:
  this

### include

public SourceTask include(String... includes)
Adds an ANT style include pattern. This method may be called multiple times to append new patterns and multiple patterns may be specified in a single call. If includes are not provided, then all files in this container will be included. If includes are provided, then a file must match at least one of the include patterns to be processed.

Specified by:
  `include` in interface `PatternFilterable`
Parameters:
  `includes` - a vararg list of include patterns
Returns:
  this
See Also:
  - Pattern Format

### include

public SourceTask include(Iterable<String> includes)
Adds an ANT style include pattern. This method may be called multiple times to append new patterns and multiple patterns may be specified in a single call. If includes are not provided, then all files in this container will be included. If includes are provided, then a file must match at least one of the include patterns to be processed.

Specified by:
  `include` in interface `PatternFilterable`
Parameters:
  `includes` - a Iterable providing more include patterns
Returns:
  this
See Also:
  - Pattern Format

### include

public SourceTask include(Spec<FileTreeElement> includeSpec)
Adds an include spec. This method may be called multiple times to append new specs. If includes are not provided, then all files in this container will be included. If includes are provided, then a file must match at least one of the include patterns or specs to be included.

Specified by:
  `include` in interface `PatternFilterable`
Parameters:
  `includeSpec` - the spec to add
Returns:
  this
See Also:
  - Pattern Format

### include

public SourceTask include(Closure includeSpec)
Adds an include spec. This method may be called multiple times to append new specs. The given closure is passed a `FileTreeElement` as its parameter. If includes are not provided, then all files in this container will be included. If includes are provided, then a file must match at least one of the include patterns or specs to be included.

Specified by:
  `include` in interface `PatternFilterable`
Parameters:
  `includeSpec` - the spec to add
Returns:
  this
See Also:
  - Pattern Format

### exclude

public SourceTask exclude(String... excludes)
Adds an ANT style exclude pattern. This method may be called multiple times to append new patterns and multiple patterns may be specified in a single call. If excludes are not provided, then no files will be excluded. If excludes are provided, then files must not match any exclude pattern to be processed.

Specified by:
  `exclude` in interface `PatternFilterable`
Parameters:
  `excludes` - a vararg list of exclude patterns
Returns:
  this
See Also:
  - Pattern Format

### exclude

public SourceTask exclude(Iterable<String> excludes)
Adds an ANT style exclude pattern. This method may be called multiple times to append new patterns and multiple patterns may be specified in a single call. If excludes are not provided, then no files will be excluded. If excludes are provided, then files must not match any exclude pattern to be processed.

Specified by:
  `exclude` in interface `PatternFilterable`
Parameters:
  `excludes` - a Iterable providing new exclude patterns
Returns:
  this
See Also:
  - Pattern Format

### exclude

public SourceTask exclude(Spec<FileTreeElement> excludeSpec)
Adds an exclude spec. This method may be called multiple times to append new specs. If excludes are not provided, then no files will be excluded. If excludes are provided, then files must not match any exclude pattern to be processed.

Specified by:
  `exclude` in interface `PatternFilterable`
Parameters:
  `excludeSpec` - the spec to add
Returns:
  this
See Also:
  - Pattern Format

### exclude

public SourceTask exclude(Closure excludeSpec)
Adds an exclude spec. This method may be called multiple times to append new specs.The given closure is passed a `FileTreeElement` as its parameter. The closure should return true or false. Example:

    copySpec {
      from 'source'
      into 'destination'
      //an example of excluding files from certain configuration:
      exclude { it.file in configurations.someConf.files }
    }

If excludes are not provided, then no files will be excluded. If excludes are provided, then files must not match any exclude pattern to be processed.

Specified by:
  `exclude` in interface `PatternFilterable`
Parameters:
  `excludeSpec` - the spec to add
Returns:
  this
See Also:
  - `FileTreeElement`

### getIncludes

@Internal public Set<String> getIncludes()
Returns the set of include patterns.

Specified by:
  `getIncludes` in interface `PatternFilterable`
Returns:
  The include patterns. Returns an empty set when there are no include patterns.

### setIncludes

public SourceTask setIncludes(Iterable<String> includes)
Set the allowable include patterns. Note that unlike `PatternFilterable.include(Iterable)` this replaces any previously defined includes.

Specified by:
  `setIncludes` in interface `PatternFilterable`
Parameters:
  `includes` - an Iterable providing new include patterns
Returns:
  this
See Also:
  - Pattern Format

### getExcludes

@Internal public Set<String> getExcludes()
Returns the set of exclude patterns.

Specified by:
  `getExcludes` in interface `PatternFilterable`
Returns:
  The exclude patterns. Returns an empty set when there are no exclude patterns.

### setExcludes

public SourceTask setExcludes(Iterable<String> excludes)
Set the allowable exclude patterns. Note that unlike `PatternFilterable.exclude(Iterable)` this replaces any previously defined excludes.

Specified by:
  `setExcludes` in interface `PatternFilterable`
Parameters:
  `excludes` - an Iterable providing new exclude patterns
Returns:
  this
See Also:
  - Pattern Format