Class Delete

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

    @DisableCachingByDefault(because="Deletion cannot be cached")
    public abstract 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.
    • Constructor Detail

      • Delete

        public Delete()
    • Method Detail

      • clean

        protected void clean()
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • 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 java.util.Set<java.lang.Object> getDelete()
        Returns the set of files which will be deleted by this task.
        Returns:
        The files. Never returns null.
      • setDelete

        public void setDelete​(java.util.Set<java.lang.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​(java.lang.Object target)
        Sets the files to be deleted by this task.
        Parameters:
        target - Any type of object accepted by Project.files(Object...)
      • isFollowSymlinks

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

        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.
      • getDeleter

        @Inject
        protected org.gradle.internal.file.Deleter getDeleter()