java.lang.Comparable<Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.TaskInternal, ExtensionAware, Task, Configurable<Task>AbstractConfigurationReportTask, AbstractLinkTask, AbstractNativeCompileTask, AbstractPublishToMaven, Assemble, BuildEnvironmentReportTask, ComponentReport, org.gradle.api.internal.ConventionTask, CreateStaticLibrary, DependencyInsightReportTask, DependentComponentsReport, ExtractSymbols, GenerateBuildDashboard, GenerateCUnitLauncher, GenerateIvyDescriptor, GenerateMavenPom, GenerateModuleMetadata, GeneratePluginDescriptors, GenerateSwiftPackageManagerManifest, InitBuild, InstallExecutable, InstallXCTestBundle, JacocoBase, ModelReport, PluginUnderTestMetadata, PrefixHeaderFileGenerateTask, PublishToIvyRepository, Sign, StripSymbols, SwiftCompile, TestReport, UnexportMainSymbol, ValidatePlugins, WindowsResourceCompile, Wrapper, WriteProperties@DisableCachingByDefault(because="Gradle would require more information to cache this task") public class DefaultTask extends org.gradle.api.internal.AbstractTask implements Task
DefaultTask is the standard Task implementation. You can extend this to implement your own task types.Task.NamerTASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE| Constructor | Description |
|---|---|
DefaultTask() |
| Modifier and Type | Method | Description |
|---|---|---|
int |
compareTo(Task otherTask) |
|
Task |
configure(Closure closure) |
Applies the statements of the closure against this task object.
|
Task |
dependsOn(java.lang.Object... paths) |
Adds the given dependencies to this task.
|
Task |
doFirst(Closure action) |
Adds the given closure to the beginning of this task's action list.
|
Task |
doFirst(java.lang.String actionName,
Action<? super Task> action) |
Adds the given
Action to the beginning of this task's action list. |
Task |
doFirst(Action<? super Task> action) |
Adds the given
Action to the beginning of this task's action list. |
Task |
doLast(Closure action) |
Adds the given closure to the end of this task's action list.
|
Task |
doLast(java.lang.String actionName,
Action<? super Task> action) |
Adds the given
Action to the end of this task's action list. |
Task |
doLast(Action<? super Task> action) |
Adds the given
Action to the end of this task's action list. |
Task |
finalizedBy(java.lang.Object... paths) |
Adds the given finalizer tasks for this task.
|
java.util.List<Action<? super Task>> |
getActions() |
Returns the sequence of
Action objects which will be executed by this task, in the order of
execution. |
AntBuilder |
getAnt() |
Returns the
AntBuilder for this task. |
java.util.Set<java.lang.Object> |
getDependsOn() |
Returns the dependencies of this task.
|
java.lang.String |
getDescription() |
Returns the description of this task.
|
TaskDestroyables |
getDestroyables() |
Returns the destroyables of this task.
|
boolean |
getDidWork() |
Checks if the task actually did any work.
|
boolean |
getEnabled() |
Returns if this task is enabled or not.
|
ExtensionContainer |
getExtensions() |
The container of extensions.
|
TaskDependency |
getFinalizedBy() |
Returns tasks that finalize this task.
|
java.lang.String |
getGroup() |
Returns the task group which this task belongs to.
|
org.gradle.api.internal.TaskInputsInternal |
getInputs() |
Returns the inputs of this task.
|
TaskLocalState |
getLocalState() |
Returns the local state of this task.
|
Logger |
getLogger() |
Returns the logger for this task.
|
LoggingManager |
getLogging() |
Returns the
LoggingManager which can be used to receive logging and to control the
standard output/error capture for this task. |
TaskDependency |
getMustRunAfter() |
Returns tasks that this task must run after.
|
java.lang.String |
getName() |
Returns the name of this task.
|
org.gradle.api.internal.TaskOutputsInternal |
getOutputs() |
Returns the outputs of this task.
|
java.lang.String |
getPath() |
Returns the path of the task, which is a fully qualified name for the task.
|
Project |
getProject() |
Returns the
Project which this task belongs to. |
TaskDependency |
getShouldRunAfter() |
Returns tasks that this task should run after.
|
org.gradle.api.internal.tasks.TaskStateInternal |
getState() |
Returns the execution state of this task.
|
org.gradle.api.internal.tasks.TaskDependencyInternal |
getTaskDependencies() |
Returns a
TaskDependency which contains all the tasks that this task depends on. |
java.io.File |
getTemporaryDir() |
Returns a directory which this task can use to write temporary files to.
|
Property<java.time.Duration> |
getTimeout() |
The timeout of this task.
|
boolean |
hasProperty(java.lang.String propertyName) |
Determines if this task has the given property.
|
Task |
mustRunAfter(java.lang.Object... paths) |
Specifies that this task must run after all of the supplied tasks.
|
void |
onlyIf(Closure onlyIfClosure) |
Execute the task only if the given closure returns true.
|
void |
onlyIf(java.lang.String onlyIfReason,
Spec<? super Task> spec) |
Execute the task only if the given spec is satisfied.
|
void |
onlyIf(Spec<? super Task> spec) |
Execute the task only if the given spec is satisfied.
|
java.lang.Object |
property(java.lang.String propertyName) |
Returns the value of the given property of this task.
|
void |
setActions(java.util.List<Action<? super Task>> replacements) |
Sets the sequence of
Action objects which will be executed by this task. |
void |
setDependsOn(java.lang.Iterable<?> dependsOn) |
Sets the dependencies of this task.
|
void |
setDescription(java.lang.String description) |
Sets a description for this task.
|
void |
setDidWork(boolean didWork) |
Sets whether the task actually did any work.
|
void |
setEnabled(boolean enabled) |
Set the enabled state of a task.
|
void |
setFinalizedBy(java.lang.Iterable<?> finalizedByTasks) |
Specifies the set of finalizer tasks for this task.
|
void |
setGroup(java.lang.String group) |
Sets the task group which this task belongs to.
|
void |
setMustRunAfter(java.lang.Iterable<?> mustRunAfterTasks) |
Specifies the set of tasks that this task must run after.
|
void |
setOnlyIf(Closure onlyIfClosure) |
Execute the task only if the given closure returns true.
|
void |
setOnlyIf(java.lang.String onlyIfReason,
Spec<? super Task> spec) |
Execute the task only if the given spec is satisfied.
|
void |
setOnlyIf(Spec<? super Task> spec) |
Execute the task only if the given spec is satisfied.
|
void |
setProperty(java.lang.String name,
java.lang.Object value) |
Sets a property of this task.
|
void |
setShouldRunAfter(java.lang.Iterable<?> shouldRunAfterTasks) |
Specifies the set of tasks that this task should run after.
|
TaskDependency |
shouldRunAfter(java.lang.Object... paths) |
Specifies that this task should run after all of the supplied tasks.
|
void |
usesService(Provider<? extends BuildService<?>> service) |
Registers a
BuildService that is used by this task so
its constraint on parallel execution can be honored. |
appendParallelSafeAction, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, setImpliesSubProjectsclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdoNotTrackState, getConvention, notCompatibleWithConfigurationCachepublic AntBuilder getAnt()
TaskReturns the AntBuilder for this task. You can use this in your build file to execute ant
tasks.
public Project getProject()
TaskReturns the Project which this task belongs to.
Calling this method from a task action is not supported when configuration caching is enabled.
getProject in interface TaskgetProject in class org.gradle.api.internal.AbstractTaskpublic java.lang.String getName()
TaskReturns the name of this task. The name uniquely identifies the task within its Project.
public java.util.List<Action<? super Task>> getActions()
TaskReturns the sequence of Action objects which will be executed by this task, in the order of
execution.
getActions in interface TaskgetActions in class org.gradle.api.internal.AbstractTaskpublic void setActions(java.util.List<Action<? super Task>> replacements)
TaskSets the sequence of Action objects which will be executed by this task.
setActions in interface TasksetActions in class org.gradle.api.internal.AbstractTaskreplacements - The actions.public java.util.Set<java.lang.Object> getDependsOn()
TaskReturns the dependencies of this task.
getDependsOn in interface TaskgetDependsOn in class org.gradle.api.internal.AbstractTaskpublic void setDependsOn(java.lang.Iterable<?> dependsOn)
TaskSets the dependencies of this task. See here for a description of the types of objects which can be used as task dependencies.
setDependsOn in interface TasksetDependsOn in class org.gradle.api.internal.AbstractTaskdependsOn - The set of task paths.public void onlyIf(Spec<? super Task> spec)
TaskExecute the task only if the given spec is satisfied. The spec will be evaluated at task execution time, not during configuration. If the Spec is not satisfied, the task will be skipped.
You may add multiple such predicates. The task is skipped if any of the predicates return false.
Typical usage (from Java):
myTask.onlyIf(new Spec<Task>() {
boolean isSatisfiedBy(Task task) {
return isProductionEnvironment();
}
});
public void onlyIf(java.lang.String onlyIfReason,
Spec<? super Task> spec)
TaskExecute the task only if the given spec is satisfied. The spec will be evaluated at task execution time, not during configuration. If the Spec is not satisfied, the task will be skipped.
You may add multiple such predicates. The task is skipped if any of the predicates return false.
Typical usage (from Java):
myTask.onlyIf("run only in production environment", new Spec<Task>() {
boolean isSatisfiedBy(Task task) {
return isProductionEnvironment();
}
});
public void setOnlyIf(Spec<? super Task> spec)
TaskExecute the task only if the given spec is satisfied. The spec will be evaluated at task execution time, not during configuration. If the Spec is not satisfied, the task will be skipped.
The given predicate replaces all such predicates for this task.
public void setOnlyIf(java.lang.String onlyIfReason,
Spec<? super Task> spec)
TaskExecute the task only if the given spec is satisfied. The spec will be evaluated at task execution time, not during configuration. If the Spec is not satisfied, the task will be skipped.
The given predicate replaces all such predicates for this task.
public boolean getDidWork()
TaskChecks if the task actually did any work. Even if a Task executes, it may determine that it has nothing to do. For example, a compilation task may determine that source files have not changed since the last time a the task was run.
getDidWork in interface TaskgetDidWork in class org.gradle.api.internal.AbstractTaskpublic void setDidWork(boolean didWork)
TasksetDidWork in interface TasksetDidWork in class org.gradle.api.internal.AbstractTaskdidWork - indicates if the task did any workpublic boolean getEnabled()
TaskReturns if this task is enabled or not.
getEnabled in interface TaskgetEnabled in class org.gradle.api.internal.AbstractTaskTask.setEnabled(boolean)public void setEnabled(boolean enabled)
TaskSet the enabled state of a task. If a task is disabled none of the its actions are executed. Note that disabling a task does not prevent the execution of the tasks which this task depends on.
setEnabled in interface TasksetEnabled in class org.gradle.api.internal.AbstractTaskenabled - The enabled state of this task (true or false)public java.lang.String getPath()
TaskReturns the path of the task, which is a fully qualified name for the task. The path of a task is the path of
its Project plus the name of the task, separated by :.
public Task dependsOn(java.lang.Object... paths)
TaskAdds the given dependencies to this task. See here for a description of the types of objects which can be used as task dependencies.
public Task doFirst(Action<? super Task> action)
TaskAdds the given Action to the beginning of this task's action list.
public Task doFirst(java.lang.String actionName, Action<? super Task> action)
TaskAdds the given Action to the beginning of this task's action list.
public Task doLast(Action<? super Task> action)
TaskAdds the given Action to the end of this task's action list.
public Task doLast(java.lang.String actionName, Action<? super Task> action)
TaskAdds the given Action to the end of this task's action list.
public int compareTo(Task otherTask)
compareTo in interface java.lang.Comparable<Task>compareTo in class org.gradle.api.internal.AbstractTaskpublic Logger getLogger()
TaskReturns the logger for this task. You can use this in your build file to write log messages.
public java.lang.Object property(java.lang.String propertyName)
throws MissingPropertyException
TaskReturns the value of the given property of this task. This method locates a property as follows:
MissingPropertyExceptionproperty in interface Taskproperty in class org.gradle.api.internal.AbstractTaskpropertyName - The name of the property.MissingPropertyException - When the given property is unknown.public boolean hasProperty(java.lang.String propertyName)
TaskDetermines if this task has the given property. See here for details of the properties which are available for a task.
hasProperty in interface TaskhasProperty in class org.gradle.api.internal.AbstractTaskpropertyName - The name of the property to locate.public void setProperty(java.lang.String name,
java.lang.Object value)
TaskSets a property of this task. This method searches for a property with the given name in the following locations, and sets the property on the first location where it finds the property.
enabled project property.MissingPropertyException is thrown.setProperty in interface TasksetProperty in class org.gradle.api.internal.AbstractTaskname - The name of the propertyvalue - The value of the propertypublic java.lang.String getDescription()
TaskgetDescription in interface TaskgetDescription in class org.gradle.api.internal.AbstractTaskpublic void setDescription(java.lang.String description)
Taskgradle tasks is called.setDescription in interface TasksetDescription in class org.gradle.api.internal.AbstractTaskdescription - The description of the task. Might be null.public java.lang.String getGroup()
Taskpublic void setGroup(java.lang.String group)
Taskpublic TaskDestroyables getDestroyables()
TaskReturns the destroyables of this task.
getDestroyables in interface TaskgetDestroyables in class org.gradle.api.internal.AbstractTaskpublic TaskLocalState getLocalState()
TaskgetLocalState in interface TaskgetLocalState in class org.gradle.api.internal.AbstractTaskpublic java.io.File getTemporaryDir()
TaskReturns a directory which this task can use to write temporary files to. Each task instance is provided with a separate temporary directory. There are no guarantees that the contents of this directory will be kept beyond the execution of the task.
getTemporaryDir in interface TaskgetTemporaryDir in class org.gradle.api.internal.AbstractTaskpublic void setMustRunAfter(java.lang.Iterable<?> mustRunAfterTasks)
TaskSpecifies the set of tasks that this task must run after.
task taskY {
mustRunAfter = ["taskX1", "taskX2"]
}
For each supplied task, this action adds a task 'ordering', and does not specify a 'dependency' between the tasks. As such, it is still possible to execute 'taskY' without first executing the 'taskX' in the example.
See here for a description of the types of objects which can be used to specify an ordering relationship.
setMustRunAfter in interface TasksetMustRunAfter in class org.gradle.api.internal.AbstractTaskmustRunAfterTasks - The set of task paths this task must run after.public Task mustRunAfter(java.lang.Object... paths)
TaskSpecifies that this task must run after all of the supplied tasks.
task taskY {
mustRunAfter "taskX"
}
For each supplied task, this action adds a task 'ordering', and does not specify a 'dependency' between the tasks. As such, it is still possible to execute 'taskY' without first executing the 'taskX' in the example.
See here for a description of the types of objects which can be used to specify an ordering relationship.
mustRunAfter in interface TaskmustRunAfter in class org.gradle.api.internal.AbstractTaskpaths - The tasks this task must run after.public TaskDependency getMustRunAfter()
TaskReturns tasks that this task must run after.
getMustRunAfter in interface TaskgetMustRunAfter in class org.gradle.api.internal.AbstractTaskpublic void setFinalizedBy(java.lang.Iterable<?> finalizedByTasks)
TaskSpecifies the set of finalizer tasks for this task.
task taskY {
finalizedBy = ["taskX1", "taskX2"]
}
See here for a description of the types of objects which can be used to specify a finalizer task.
setFinalizedBy in interface TasksetFinalizedBy in class org.gradle.api.internal.AbstractTaskfinalizedByTasks - The tasks that finalize this task.public Task finalizedBy(java.lang.Object... paths)
TaskAdds the given finalizer tasks for this task.
task taskY {
finalizedBy "taskX"
}
See here for a description of the types of objects which can be used to specify a finalizer task.
finalizedBy in interface TaskfinalizedBy in class org.gradle.api.internal.AbstractTaskpaths - The tasks that finalize this task.public TaskDependency getFinalizedBy()
TaskReturns tasks that finalize this task.
getFinalizedBy in interface TaskgetFinalizedBy in class org.gradle.api.internal.AbstractTaskpublic TaskDependency shouldRunAfter(java.lang.Object... paths)
TaskSpecifies that this task should run after all of the supplied tasks.
task taskY {
shouldRunAfter "taskX"
}
For each supplied task, this action adds a task 'ordering', and does not specify a 'dependency' between the tasks. As such, it is still possible to execute 'taskY' without first executing the 'taskX' in the example.
See here for a description of the types of objects which can be used to specify an ordering relationship.
shouldRunAfter in interface TaskshouldRunAfter in class org.gradle.api.internal.AbstractTaskpaths - The tasks this task should run after.public void setShouldRunAfter(java.lang.Iterable<?> shouldRunAfterTasks)
TaskSpecifies the set of tasks that this task should run after.
task taskY {
shouldRunAfter = ["taskX1", "taskX2"]
}
For each supplied task, this action adds a task 'ordering', and does not specify a 'dependency' between the tasks. As such, it is still possible to execute 'taskY' without first executing the 'taskX' in the example.
See here for a description of the types of objects which can be used to specify an ordering relationship.
setShouldRunAfter in interface TasksetShouldRunAfter in class org.gradle.api.internal.AbstractTaskshouldRunAfterTasks - The set of task paths this task should run after.public TaskDependency getShouldRunAfter()
TaskReturns tasks that this task should run after.
getShouldRunAfter in interface TaskgetShouldRunAfter in class org.gradle.api.internal.AbstractTaskpublic Property<java.time.Duration> getTimeout()
TaskThe timeout of this task.
task myTask {
timeout = Duration.ofMinutes(10)
}
The Thread executing this task will be interrupted if the task takes longer than the specified amount of time to run. In order for a task to work properly with this feature, it needs to react to interrupts and must clean up any resources it opened.
By default, tasks never time out.
getTimeout in interface TaskgetTimeout in class org.gradle.api.internal.AbstractTaskpublic void usesService(Provider<? extends BuildService<?>> service)
TaskBuildService that is used by this task so
its constraint on parallel execution can be honored.usesService in interface TaskusesService in class org.gradle.api.internal.AbstractTaskservice - The service provider.public org.gradle.api.internal.tasks.TaskStateInternal getState()
Taskpublic org.gradle.api.internal.tasks.TaskDependencyInternal getTaskDependencies()
TaskReturns a TaskDependency which contains all the tasks that this task depends on.
Calling this method from a task action is not supported when configuration caching is enabled.
getTaskDependencies in interface TaskgetTaskDependencies in class org.gradle.api.internal.AbstractTaskpublic void onlyIf(Closure onlyIfClosure)
TaskExecute the task only if the given closure returns true. The closure will be evaluated at task execution time, not during configuration. The closure will be passed a single parameter, this task. If the closure returns false, the task will be skipped.
You may add multiple such predicates. The task is skipped if any of the predicates return false.
Typical usage:myTask.onlyIf { isProductionEnvironment() }
public void setOnlyIf(Closure onlyIfClosure)
TaskExecute the task only if the given closure returns true. The closure will be evaluated at task execution time, not during configuration. The closure will be passed a single parameter, this task. If the closure returns false, the task will be skipped.
The given predicate replaces all such predicates for this task.
public LoggingManager getLogging()
TaskLoggingManager which can be used to receive logging and to control the
standard output/error capture for this task. By default, System.out is redirected to the Gradle logging system at
the QUIET log level, and System.err is redirected at the ERROR log level.getLogging in interface TaskgetLogging in class org.gradle.api.internal.AbstractTaskpublic org.gradle.api.internal.TaskInputsInternal getInputs()
TaskReturns the inputs of this task.
public org.gradle.api.internal.TaskOutputsInternal getOutputs()
TaskReturns the outputs of this task.
getOutputs in interface TaskgetOutputs in interface org.gradle.api.internal.TaskInternalgetOutputs in class org.gradle.api.internal.AbstractTaskpublic Task doFirst(Closure action)
TaskAdds the given closure to the beginning of this task's action list. The closure is passed this task as a parameter when executed.
public Task doLast(Closure action)
TaskAdds the given closure to the end of this task's action list. The closure is passed this task as a parameter when executed.
public Task configure(Closure closure)
TaskApplies the statements of the closure against this task object. The delegate object for the closure is set to this task.
configure in interface Configurable<Task>configure in interface Taskconfigure in class org.gradle.api.internal.AbstractTaskclosure - The closure to be applied (can be null).public ExtensionContainer getExtensions()
ExtensionAwaregetExtensions in interface ExtensionAwaregetExtensions in class org.gradle.api.internal.AbstractTask