Class Delete

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

    public class Delete
    extends org.gradle.api.internal.ConventionTask
    implements DeleteSpec

    Deletes files or directories. Example:

     task makePretty(type: Delete) {
       delete 'uglyFolder', 'uglyFile'
       followSymlinks = true
     }
     
    Be default symlinks will not be followed when deleting files. To change this behavior call setFollowSymlinks(boolean) with true. On systems that do not support symlinks, this will have no effect.
    • Nested Class Summary

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

        Task.Namer
    • Constructor Summary

      Constructors 
      Constructor Description
      Delete()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void clean()  
      Delete delete​(Object... targets)
      Adds some files to be deleted by this task.
      Set<Object> getDelete()
      Returns the set of files which will be deleted by this task.
      protected org.gradle.api.internal.file.FileResolver getFileResolver()  
      protected org.gradle.internal.nativeintegration.filesystem.FileSystem getFileSystem()  
      FileCollection getTargetFiles()
      Returns the resolved set of files which will be deleted by this task.
      boolean isFollowSymlinks()
      Returns if symlinks should be followed when doing a delete.
      void setDelete​(Object target)
      Sets the files to be deleted by this task.
      void setDelete​(Set<Object> targets)
      Sets the files to be deleted by this task.
      void setFollowSymlinks​(boolean followSymlinks)
      Set if symlinks should be followed.
      • Methods inherited from class org.gradle.api.internal.ConventionTask

        conventionMapping, conventionMapping, getConventionMapping
      • 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
    • Constructor Detail

      • Delete

        public Delete()
    • Method Detail

      • getFileSystem

        @Inject
        protected org.gradle.internal.nativeintegration.filesystem.FileSystem getFileSystem()
      • getFileResolver

        @Inject
        protected org.gradle.api.internal.file.FileResolver getFileResolver()
      • clean

        protected void clean()
      • getTargetFiles

        @Destroys
        public FileCollection getTargetFiles()
        Returns the resolved set of files which will be deleted by this task.
        Returns:
        The files. Never returns null.
      • getDelete

        @Internal
        public Set<Object> getDelete()
        Returns the set of files which will be deleted by this task.
        Returns:
        The files. Never returns null.
      • setDelete

        public void setDelete​(Set<Object> targets)
        Sets the files to be deleted by this task.
        Parameters:
        targets - A set of any type of object accepted by Project.files(Object...)
        Since:
        4.0
      • setDelete

        public void setDelete​(Object target)
        Sets the files to be deleted by this task.
        Parameters:
        target - Any type of object accepted by Project.files(Object...)
      • isFollowSymlinks

        @Incubating
        @Input
        public boolean isFollowSymlinks()
        Returns if symlinks should be followed when doing a delete.
        Returns:
        true if symlinks will be followed.
      • setFollowSymlinks

        @Incubating
        public void setFollowSymlinks​(boolean followSymlinks)
        Set if symlinks should be followed. If the platform doesn't support symlinks, then this will have no effect.
        Specified by:
        setFollowSymlinks in interface DeleteSpec
        Parameters:
        followSymlinks - if symlinks should be followed.