Package org.gradle.api.tasks
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:
java.lang.Comparable<Task>
,org.gradle.api.internal.DynamicObjectAware
,org.gradle.api.internal.IConventionAware
,org.gradle.api.internal.TaskInternal
,Named
,ExtensionAware
,Task
,PatternFilterable
,Configurable<Task>
- Direct Known Subclasses:
AbstractCodeQualityTask
,AbstractCompile
,AntlrTask
,Groovydoc
,Javadoc
,ScalaDoc
@NonNullApi @DisableCachingByDefault(because="Super-class, not to be instantiated directly") public abstract class SourceTask extends org.gradle.api.internal.ConventionTask implements PatternFilterable
ASourceTask
performs some operation on source files.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.gradle.api.Task
Task.Namer
-
-
Field Summary
-
Fields inherited from interface org.gradle.api.Task
TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
-
-
Constructor Summary
Constructors Constructor Description SourceTask()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SourceTask
exclude(Closure excludeSpec)
Adds an exclude spec.SourceTask
exclude(java.lang.Iterable<java.lang.String> excludes)
Adds an ANT style exclude pattern.SourceTask
exclude(java.lang.String... excludes)
Adds an ANT style exclude pattern.SourceTask
exclude(Spec<FileTreeElement> excludeSpec)
Adds an exclude spec.java.util.Set<java.lang.String>
getExcludes()
Returns the set of exclude patterns.java.util.Set<java.lang.String>
getIncludes()
Returns the set of include patterns.protected PatternFilterable
getPatternSet()
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(java.lang.Iterable<java.lang.String> includes)
Adds an ANT style include pattern.SourceTask
include(java.lang.String... includes)
Adds an ANT style include pattern.SourceTask
include(Spec<FileTreeElement> includeSpec)
Adds an include spec.SourceTask
setExcludes(java.lang.Iterable<java.lang.String> excludes)
Set the allowable exclude patterns.SourceTask
setIncludes(java.lang.Iterable<java.lang.String> includes)
Set the allowable include patterns.void
setSource(java.lang.Object source)
Sets the source for this task.void
setSource(FileTree source)
Sets the source for this task.SourceTask
source(java.lang.Object... sources)
Adds some source to this task.-
Methods inherited from class org.gradle.api.internal.ConventionTask
conventionMapping, conventionMapping, getConventionMapping
-
Methods inherited from class org.gradle.api.DefaultTask
compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService
-
Methods inherited from class org.gradle.api.internal.AbstractTask
acceptServiceReferences, appendParallelSafeAction, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, setImpliesSubProjects
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.gradle.api.Task
doNotTrackState, getConvention, notCompatibleWithConfigurationCache
-
-
-
-
Method Detail
-
getPatternSetFactory
@Inject protected org.gradle.internal.Factory<PatternSet> getPatternSetFactory()
-
getPatternSet
@Internal protected PatternFilterable getPatternSet()
-
getSource
@InputFiles @SkipWhenEmpty @IgnoreEmptyDirectories @PathSensitive(ABSOLUTE) 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.The
PathSensitivity
for the sources is configured to bePathSensitivity.ABSOLUTE
. If your sources are less strict, please change it accordingly by overriding this method in your subclass.- 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(java.lang.Object source)
Sets the source for this task. The given source object is evaluated as perProject.files(Object...)
.- Parameters:
source
- The source.
-
source
public SourceTask source(java.lang.Object... sources)
Adds some source to this task. The given source objects will be evaluated as perProject.files(Object...)
.- Parameters:
sources
- The source to add- Returns:
- this
-
include
public SourceTask include(java.lang.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 interfacePatternFilterable
- Parameters:
includes
- a vararg list of include patterns- Returns:
- this
- See Also:
Pattern Format
-
include
public SourceTask include(java.lang.Iterable<java.lang.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 interfacePatternFilterable
- 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 interfacePatternFilterable
- 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 aFileTreeElement
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 interfacePatternFilterable
- Parameters:
includeSpec
- the spec to add- Returns:
- this
- See Also:
Pattern Format
-
exclude
public SourceTask exclude(java.lang.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 interfacePatternFilterable
- Parameters:
excludes
- a vararg list of exclude patterns- Returns:
- this
- See Also:
Pattern Format
-
exclude
public SourceTask exclude(java.lang.Iterable<java.lang.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 interfacePatternFilterable
- 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 interfacePatternFilterable
- 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 aFileTreeElement
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 interfacePatternFilterable
- Parameters:
excludeSpec
- the spec to add- Returns:
- this
- See Also:
FileTreeElement
-
getIncludes
@Internal public java.util.Set<java.lang.String> getIncludes()
Returns the set of include patterns.- Specified by:
getIncludes
in interfacePatternFilterable
- Returns:
- The include patterns. Returns an empty set when there are no include patterns.
-
setIncludes
public SourceTask setIncludes(java.lang.Iterable<java.lang.String> includes)
Set the allowable include patterns. Note that unlikePatternFilterable.include(Iterable)
this replaces any previously defined includes.- Specified by:
setIncludes
in interfacePatternFilterable
- Parameters:
includes
- an Iterable providing new include patterns- Returns:
- this
- See Also:
Pattern Format
-
getExcludes
@Internal public java.util.Set<java.lang.String> getExcludes()
Returns the set of exclude patterns.- Specified by:
getExcludes
in interfacePatternFilterable
- Returns:
- The exclude patterns. Returns an empty set when there are no exclude patterns.
-
setExcludes
public SourceTask setExcludes(java.lang.Iterable<java.lang.String> excludes)
Set the allowable exclude patterns. Note that unlikePatternFilterable.exclude(Iterable)
this replaces any previously defined excludes.- Specified by:
setExcludes
in interfacePatternFilterable
- Parameters:
excludes
- an Iterable providing new exclude patterns- Returns:
- this
- See Also:
Pattern Format
-
-