Class DefaultTask

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.gradle.api.Task

        Task.Namer
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultTask()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      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.
      • 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
    • Constructor Detail

      • DefaultTask

        public DefaultTask()
    • Method Detail

      • getAnt

        public AntBuilder getAnt()
        Description copied from interface: Task

        Returns the AntBuilder for this task. You can use this in your build file to execute ant tasks.

        Specified by:
        getAnt in interface Task
        Overrides:
        getAnt in class org.gradle.api.internal.AbstractTask
        Returns:
        The AntBuilder
      • getProject

        public Project getProject()
        Description copied from interface: Task

        Returns the Project which this task belongs to.

        Calling this method from a task action is not supported when configuration caching is enabled.

        Specified by:
        getProject in interface Task
        Overrides:
        getProject in class org.gradle.api.internal.AbstractTask
        Returns:
        The project this task belongs to. Never returns null.
      • getName

        public java.lang.String getName()
        Description copied from interface: Task

        Returns the name of this task. The name uniquely identifies the task within its Project.

        Specified by:
        getName in interface Named
        Specified by:
        getName in interface Task
        Overrides:
        getName in class org.gradle.api.internal.AbstractTask
        Returns:
        The name of the task. Never returns null.
      • getActions

        public java.util.List<Action<? super Task>> getActions()
        Description copied from interface: Task

        Returns the sequence of Action objects which will be executed by this task, in the order of execution.

        Specified by:
        getActions in interface Task
        Overrides:
        getActions in class org.gradle.api.internal.AbstractTask
        Returns:
        The task actions in the order they are executed. Returns an empty list if this task has no actions.
      • setActions

        public void setActions​(java.util.List<Action<? super Task>> replacements)
        Description copied from interface: Task

        Sets the sequence of Action objects which will be executed by this task.

        Specified by:
        setActions in interface Task
        Overrides:
        setActions in class org.gradle.api.internal.AbstractTask
        Parameters:
        replacements - The actions.
      • getDependsOn

        public java.util.Set<java.lang.Object> getDependsOn()
        Description copied from interface: Task

        Returns the dependencies of this task.

        Specified by:
        getDependsOn in interface Task
        Overrides:
        getDependsOn in class org.gradle.api.internal.AbstractTask
        Returns:
        The dependencies of this task. Returns an empty set if this task has no dependencies.
      • setDependsOn

        public void setDependsOn​(java.lang.Iterable<?> dependsOn)
        Description copied from interface: Task

        Sets the dependencies of this task. See here for a description of the types of objects which can be used as task dependencies.

        Specified by:
        setDependsOn in interface Task
        Overrides:
        setDependsOn in class org.gradle.api.internal.AbstractTask
        Parameters:
        dependsOn - The set of task paths.
      • onlyIf

        public void onlyIf​(Spec<? super Task> spec)
        Description copied from interface: Task

        Execute 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();
            }
         });
         
        Specified by:
        onlyIf in interface Task
        Overrides:
        onlyIf in class org.gradle.api.internal.AbstractTask
        Parameters:
        spec - specifies if a task should be run
      • onlyIf

        public void onlyIf​(java.lang.String onlyIfReason,
                           Spec<? super Task> spec)
        Description copied from interface: Task

        Execute 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();
            }
         });
         
        Specified by:
        onlyIf in interface Task
        Overrides:
        onlyIf in class org.gradle.api.internal.AbstractTask
        Parameters:
        onlyIfReason - specifies the reason for a task to run, which is used for logging
        spec - specifies if a task should be run
      • setOnlyIf

        public void setOnlyIf​(Spec<? super Task> spec)
        Description copied from interface: Task

        Execute 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.

        Specified by:
        setOnlyIf in interface Task
        Overrides:
        setOnlyIf in class org.gradle.api.internal.AbstractTask
        Parameters:
        spec - specifies if a task should be run
      • setOnlyIf

        public void setOnlyIf​(java.lang.String onlyIfReason,
                              Spec<? super Task> spec)
        Description copied from interface: Task

        Execute 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.

        Specified by:
        setOnlyIf in interface Task
        Overrides:
        setOnlyIf in class org.gradle.api.internal.AbstractTask
        Parameters:
        onlyIfReason - specifies the reason for a task to run, which is used for logging
        spec - specifies if a task should be run
      • getDidWork

        public boolean getDidWork()
        Description copied from interface: Task

        Checks 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.

        Specified by:
        getDidWork in interface Task
        Overrides:
        getDidWork in class org.gradle.api.internal.AbstractTask
        Returns:
        true if this task did any work
      • setDidWork

        public void setDidWork​(boolean didWork)
        Description copied from interface: Task
        Sets whether the task actually did any work. Most built-in tasks will set this automatically, but it may be useful to manually indicate this for custom user tasks.
        Specified by:
        setDidWork in interface Task
        Overrides:
        setDidWork in class org.gradle.api.internal.AbstractTask
        Parameters:
        didWork - indicates if the task did any work
      • getEnabled

        public boolean getEnabled()
        Description copied from interface: Task

        Returns if this task is enabled or not.

        Specified by:
        getEnabled in interface Task
        Overrides:
        getEnabled in class org.gradle.api.internal.AbstractTask
        See Also:
        Task.setEnabled(boolean)
      • setEnabled

        public void setEnabled​(boolean enabled)
        Description copied from interface: Task

        Set 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.

        Specified by:
        setEnabled in interface Task
        Overrides:
        setEnabled in class org.gradle.api.internal.AbstractTask
        Parameters:
        enabled - The enabled state of this task (true or false)
      • getPath

        public java.lang.String getPath()
        Description copied from interface: Task

        Returns 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 :.

        Specified by:
        getPath in interface Task
        Overrides:
        getPath in class org.gradle.api.internal.AbstractTask
        Returns:
        the path of the task, which is equal to the path of the project plus the name of the task.
      • dependsOn

        public Task dependsOn​(java.lang.Object... paths)
        Description copied from interface: Task

        Adds the given dependencies to this task. See here for a description of the types of objects which can be used as task dependencies.

        Specified by:
        dependsOn in interface Task
        Overrides:
        dependsOn in class org.gradle.api.internal.AbstractTask
        Parameters:
        paths - The dependencies to add to this task.
        Returns:
        the task object this method is applied to
      • doFirst

        public Task doFirst​(Action<? super Task> action)
        Description copied from interface: Task

        Adds the given Action to the beginning of this task's action list.

        Specified by:
        doFirst in interface Task
        Overrides:
        doFirst in class org.gradle.api.internal.AbstractTask
        Parameters:
        action - The action to add
        Returns:
        the task object this method is applied to
      • doFirst

        public Task doFirst​(java.lang.String actionName,
                            Action<? super Task> action)
        Description copied from interface: Task

        Adds the given Action to the beginning of this task's action list.

        Specified by:
        doFirst in interface Task
        Overrides:
        doFirst in class org.gradle.api.internal.AbstractTask
        Parameters:
        actionName - An arbitrary string that is used for logging.
        action - The action to add
        Returns:
        the task object this method is applied to
      • doLast

        public Task doLast​(Action<? super Task> action)
        Description copied from interface: Task

        Adds the given Action to the end of this task's action list.

        Specified by:
        doLast in interface Task
        Overrides:
        doLast in class org.gradle.api.internal.AbstractTask
        Parameters:
        action - The action to add.
        Returns:
        the task object this method is applied to
      • doLast

        public Task doLast​(java.lang.String actionName,
                           Action<? super Task> action)
        Description copied from interface: Task

        Adds the given Action to the end of this task's action list.

        Specified by:
        doLast in interface Task
        Overrides:
        doLast in class org.gradle.api.internal.AbstractTask
        Parameters:
        actionName - An arbitrary string that is used for logging.
        action - The action to add.
        Returns:
        the task object this method is applied to
      • compareTo

        public int compareTo​(Task otherTask)
        Specified by:
        compareTo in interface java.lang.Comparable<Task>
        Overrides:
        compareTo in class org.gradle.api.internal.AbstractTask
      • getLogger

        public Logger getLogger()
        Description copied from interface: Task

        Returns the logger for this task. You can use this in your build file to write log messages.

        Specified by:
        getLogger in interface Task
        Overrides:
        getLogger in class org.gradle.api.internal.AbstractTask
        Returns:
        The logger. Never returns null.
      • property

        public java.lang.Object property​(java.lang.String propertyName)
                                  throws MissingPropertyException
        Description copied from interface: Task

        Returns the value of the given property of this task. This method locates a property as follows:

        1. If this task object has a property with the given name, return the value of the property.
        2. If this task has an extension with the given name, return the extension.
        3. If this task's convention object has a property with the given name, return the value of the property.
        4. If this task has an extra property with the given name, return the value of the property.
        5. If not found, throw MissingPropertyException
        Specified by:
        property in interface Task
        Overrides:
        property in class org.gradle.api.internal.AbstractTask
        Parameters:
        propertyName - The name of the property.
        Returns:
        The value of the property, possibly null.
        Throws:
        MissingPropertyException - When the given property is unknown.
      • hasProperty

        public boolean hasProperty​(java.lang.String propertyName)
        Description copied from interface: Task

        Determines if this task has the given property. See here for details of the properties which are available for a task.

        Specified by:
        hasProperty in interface Task
        Overrides:
        hasProperty in class org.gradle.api.internal.AbstractTask
        Parameters:
        propertyName - The name of the property to locate.
        Returns:
        True if this project has the given property, false otherwise.
      • setProperty

        public void setProperty​(java.lang.String name,
                                java.lang.Object value)
        Description copied from interface: Task

        Sets 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.

        1. The task object itself. For example, the enabled project property.
        2. The task's convention object.
        3. The task's extra properties.
        If the property is not found, a MissingPropertyException is thrown.
        Specified by:
        setProperty in interface Task
        Overrides:
        setProperty in class org.gradle.api.internal.AbstractTask
        Parameters:
        name - The name of the property
        value - The value of the property
      • getDescription

        public java.lang.String getDescription()
        Description copied from interface: Task
        Returns the description of this task.
        Specified by:
        getDescription in interface Task
        Overrides:
        getDescription in class org.gradle.api.internal.AbstractTask
        Returns:
        the description. May return null.
      • setDescription

        public void setDescription​(java.lang.String description)
        Description copied from interface: Task
        Sets a description for this task. This should describe what the task does to the user of the build. The description will be displayed when gradle tasks is called.
        Specified by:
        setDescription in interface Task
        Overrides:
        setDescription in class org.gradle.api.internal.AbstractTask
        Parameters:
        description - The description of the task. Might be null.
      • getGroup

        public java.lang.String getGroup()
        Description copied from interface: Task
        Returns the task group which this task belongs to. The task group is used in reports and user interfaces to group related tasks together when presenting a list of tasks to the user.
        Specified by:
        getGroup in interface Task
        Overrides:
        getGroup in class org.gradle.api.internal.AbstractTask
        Returns:
        The task group for this task. Might be null.
      • setGroup

        public void setGroup​(java.lang.String group)
        Description copied from interface: Task
        Sets the task group which this task belongs to. The task group is used in reports and user interfaces to group related tasks together when presenting a list of tasks to the user.
        Specified by:
        setGroup in interface Task
        Overrides:
        setGroup in class org.gradle.api.internal.AbstractTask
        Parameters:
        group - The task group for this task. Can be null.
      • getDestroyables

        public TaskDestroyables getDestroyables()
        Description copied from interface: Task

        Returns the destroyables of this task.

        Specified by:
        getDestroyables in interface Task
        Overrides:
        getDestroyables in class org.gradle.api.internal.AbstractTask
        Returns:
        The destroyables. Never returns null.
      • getLocalState

        public TaskLocalState getLocalState()
        Description copied from interface: Task
        Returns the local state of this task.
        Specified by:
        getLocalState in interface Task
        Overrides:
        getLocalState in class org.gradle.api.internal.AbstractTask
      • getTemporaryDir

        public java.io.File getTemporaryDir()
        Description copied from interface: Task

        Returns 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.

        Specified by:
        getTemporaryDir in interface Task
        Overrides:
        getTemporaryDir in class org.gradle.api.internal.AbstractTask
        Returns:
        The directory. Never returns null. The directory will already exist.
      • setMustRunAfter

        public void setMustRunAfter​(java.lang.Iterable<?> mustRunAfterTasks)
        Description copied from interface: Task

        Specifies 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.

        Specified by:
        setMustRunAfter in interface Task
        Overrides:
        setMustRunAfter in class org.gradle.api.internal.AbstractTask
        Parameters:
        mustRunAfterTasks - The set of task paths this task must run after.
      • mustRunAfter

        public Task mustRunAfter​(java.lang.Object... paths)
        Description copied from interface: Task

        Specifies 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.

        Specified by:
        mustRunAfter in interface Task
        Overrides:
        mustRunAfter in class org.gradle.api.internal.AbstractTask
        Parameters:
        paths - The tasks this task must run after.
        Returns:
        the task object this method is applied to
      • getMustRunAfter

        public TaskDependency getMustRunAfter()
        Description copied from interface: Task

        Returns tasks that this task must run after.

        Specified by:
        getMustRunAfter in interface Task
        Overrides:
        getMustRunAfter in class org.gradle.api.internal.AbstractTask
        Returns:
        The tasks that this task must run after. Returns an empty set if this task has no tasks it must run after.
      • setFinalizedBy

        public void setFinalizedBy​(java.lang.Iterable<?> finalizedByTasks)
        Description copied from interface: Task

        Specifies 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.

        Specified by:
        setFinalizedBy in interface Task
        Overrides:
        setFinalizedBy in class org.gradle.api.internal.AbstractTask
        Parameters:
        finalizedByTasks - The tasks that finalize this task.
      • finalizedBy

        public Task finalizedBy​(java.lang.Object... paths)
        Description copied from interface: Task

        Adds 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.

        Specified by:
        finalizedBy in interface Task
        Overrides:
        finalizedBy in class org.gradle.api.internal.AbstractTask
        Parameters:
        paths - The tasks that finalize this task.
        Returns:
        the task object this method is applied to
      • getFinalizedBy

        public TaskDependency getFinalizedBy()
        Description copied from interface: Task

        Returns tasks that finalize this task.

        Specified by:
        getFinalizedBy in interface Task
        Overrides:
        getFinalizedBy in class org.gradle.api.internal.AbstractTask
        Returns:
        The tasks that finalize this task. Returns an empty set if there are no finalising tasks for this task.
      • shouldRunAfter

        public TaskDependency shouldRunAfter​(java.lang.Object... paths)
        Description copied from interface: Task

        Specifies 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.

        Specified by:
        shouldRunAfter in interface Task
        Overrides:
        shouldRunAfter in class org.gradle.api.internal.AbstractTask
        Parameters:
        paths - The tasks this task should run after.
        Returns:
        the task object this method is applied to
      • setShouldRunAfter

        public void setShouldRunAfter​(java.lang.Iterable<?> shouldRunAfterTasks)
        Description copied from interface: Task

        Specifies 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.

        Specified by:
        setShouldRunAfter in interface Task
        Overrides:
        setShouldRunAfter in class org.gradle.api.internal.AbstractTask
        Parameters:
        shouldRunAfterTasks - The set of task paths this task should run after.
      • getShouldRunAfter

        public TaskDependency getShouldRunAfter()
        Description copied from interface: Task

        Returns tasks that this task should run after.

        Specified by:
        getShouldRunAfter in interface Task
        Overrides:
        getShouldRunAfter in class org.gradle.api.internal.AbstractTask
        Returns:
        The tasks that this task should run after. Returns an empty set if this task has no tasks it must run after.
      • getTimeout

        public Property<java.time.Duration> getTimeout()
        Description copied from interface: Task

        The 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.

        Specified by:
        getTimeout in interface Task
        Overrides:
        getTimeout in class org.gradle.api.internal.AbstractTask
      • getState

        public org.gradle.api.internal.tasks.TaskStateInternal getState()
        Description copied from interface: Task
        Returns the execution state of this task. This provides information about the execution of this task, such as whether it has executed, been skipped, has failed, etc.
        Specified by:
        getState in interface Task
        Specified by:
        getState in interface org.gradle.api.internal.TaskInternal
        Overrides:
        getState in class org.gradle.api.internal.AbstractTask
        Returns:
        The execution state of this task. Never returns null.
      • getTaskDependencies

        public org.gradle.api.internal.tasks.TaskDependencyInternal getTaskDependencies()
        Description copied from interface: Task

        Returns 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.

        Specified by:
        getTaskDependencies in interface Task
        Overrides:
        getTaskDependencies in class org.gradle.api.internal.AbstractTask
        Returns:
        The dependencies of this task. Never returns null.
      • onlyIf

        public void onlyIf​(Closure onlyIfClosure)
        Description copied from interface: Task

        Execute 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() }

        Specified by:
        onlyIf in interface Task
        Overrides:
        onlyIf in class org.gradle.api.internal.AbstractTask
        Parameters:
        onlyIfClosure - code to execute to determine if task should be run
      • setOnlyIf

        public void setOnlyIf​(Closure onlyIfClosure)
        Description copied from interface: Task

        Execute 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.

        Specified by:
        setOnlyIf in interface Task
        Overrides:
        setOnlyIf in class org.gradle.api.internal.AbstractTask
        Parameters:
        onlyIfClosure - code to execute to determine if task should be run
      • getLogging

        public LoggingManager getLogging()
        Description copied from interface: Task
        Returns the LoggingManager 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.
        Specified by:
        getLogging in interface Task
        Overrides:
        getLogging in class org.gradle.api.internal.AbstractTask
        Returns:
        the LoggingManager. Never returns null.
      • getInputs

        public org.gradle.api.internal.TaskInputsInternal getInputs()
        Description copied from interface: Task

        Returns the inputs of this task.

        Specified by:
        getInputs in interface Task
        Specified by:
        getInputs in interface org.gradle.api.internal.TaskInternal
        Overrides:
        getInputs in class org.gradle.api.internal.AbstractTask
        Returns:
        The inputs. Never returns null.
      • getOutputs

        public org.gradle.api.internal.TaskOutputsInternal getOutputs()
        Description copied from interface: Task

        Returns the outputs of this task.

        Specified by:
        getOutputs in interface Task
        Specified by:
        getOutputs in interface org.gradle.api.internal.TaskInternal
        Overrides:
        getOutputs in class org.gradle.api.internal.AbstractTask
        Returns:
        The outputs. Never returns null.
      • doFirst

        public Task doFirst​(Closure action)
        Description copied from interface: Task

        Adds the given closure to the beginning of this task's action list. The closure is passed this task as a parameter when executed.

        Specified by:
        doFirst in interface Task
        Overrides:
        doFirst in class org.gradle.api.internal.AbstractTask
        Parameters:
        action - The action closure to execute.
        Returns:
        This task.
      • doLast

        public Task doLast​(Closure action)
        Description copied from interface: Task

        Adds the given closure to the end of this task's action list. The closure is passed this task as a parameter when executed.

        Specified by:
        doLast in interface Task
        Overrides:
        doLast in class org.gradle.api.internal.AbstractTask
        Parameters:
        action - The action closure to execute.
        Returns:
        This task.
      • configure

        public Task configure​(Closure closure)
        Description copied from interface: Task

        Applies the statements of the closure against this task object. The delegate object for the closure is set to this task.

        Specified by:
        configure in interface Configurable<Task>
        Specified by:
        configure in interface Task
        Overrides:
        configure in class org.gradle.api.internal.AbstractTask
        Parameters:
        closure - The closure to be applied (can be null).
        Returns:
        This task