# Class Delete

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
org.gradle.api.internal.ConventionTask
org.gradle.api.tasks.Delete

All Implemented Interfaces:
  `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.

Since:
  0.9

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from interface Named

  `Named.Namer`

- ## Field Summary

  ### Fields inherited from interface Task

  `TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Delete()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `clean()`
  Clean.
  `Delete`
  `delete(@Nullable 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 abstract org.gradle.internal.file.Deleter`
  `getDeleter()`
  `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 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, doNotTrackStateIf, getAsDynamicObject, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getLoggingManager, getOnlyIf, getReasonNotToTrackState, getReasonsNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, restoreOnlyIf, restoreTaskActions, service, setImpliesSubProjects`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface Task

  `doNotTrackState, notCompatibleWithConfigurationCache, service`

- ## Constructor Details

  - ### Delete

    public Delete()

- ## Method Details

  - ### clean

    protected void clean() throws IOException
    Clean.
    Throws:
      `IOException`
    Since:
      0.9

  - ### getTargetFiles

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

  - ### getDelete

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

  - ### 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...)`
    Since:
      0.9

  - ### isFollowSymlinks

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

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

  - ### delete

    public Delete delete(@Nullable Object... targets)
    Adds some files to be deleted by this task. The given targets are evaluated as per `Project.files(Object...)`.
    Specified by:
      `delete` in interface `DeleteSpec`
    Parameters:
      `targets` - Any type of object accepted by `Project.files(Object...)`

  - ### getDeleter

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