Class Delete

  • All Implemented Interfaces:
    java.lang.Cloneable, SelectorContainer

    public class Delete
    extends MatchingTask
    Deletes a file or directory, or set of files defined by a fileset. The original delete task would delete a file, or a set of files using the include/exclude syntax. The deltree task would delete a directory tree. This task combines the functionality of these two originally distinct tasks.

    Currently Delete extends MatchingTask. This is intended only to provide backwards compatibility for a release. The future position is to use nested filesets exclusively.

    Ant 1.2
    • Field Detail

      • file

        protected file
      • dir

        protected dir
      • filesets

        protected java.util.Vector<FileSet> filesets
      • usedMatchingTask

        protected boolean usedMatchingTask
      • includeEmpty

        protected boolean includeEmpty
    • Constructor Detail

      • Delete

        public Delete()
    • Method Detail

      • setFile

        public void setFile​( file)
        Set the name of a single file to be removed.
        file - the file to be deleted
      • setDir

        public void setDir​( dir)
        Set the directory from which files are to be deleted
        dir - the directory path.
      • setVerbose

        public void setVerbose​(boolean verbose)
        If true, list all names of deleted files.
        verbose - "true" or "on"
      • setQuiet

        public void setQuiet​(boolean quiet)
        If true and the file does not exist, do not display a diagnostic message or modify the exit status to reflect an error. This means that if a file or directory cannot be deleted, then no error is reported. This setting emulates the -f option to the Unix "rm" command. Default is false meaning things are "noisy"
        quiet - "true" or "on"
      • setFailOnError

        public void setFailOnError​(boolean failonerror)
        If false, note errors but continue.
        failonerror - true or false
      • setDeleteOnExit

        public void setDeleteOnExit​(boolean deleteOnExit)
        If true, on failure to delete, note the error and set the deleteonexit flag, and continue
        deleteOnExit - true or false
      • setIncludeEmptyDirs

        public void setIncludeEmptyDirs​(boolean includeEmpty)
        If true, delete empty directories.
        includeEmpty - if true delete empty directories (only for filesets). Default is false.
      • setPerformGcOnFailedDelete

        public void setPerformGcOnFailedDelete​(boolean b)
        Whether to perform a garbage collection before retrying a failed delete.

        This may be required on Windows (where it is set to true by default) but also on other operating systems, for example when deleting directories from an NFS share.

        b - boolean
        Ant 1.8.3
      • addFileset

        public void addFileset​(FileSet set)
        Adds a set of files to be deleted.
        set - the set of files to be deleted
      • add

        public void add​(ResourceCollection rc)
        Add an arbitrary ResourceCollection to be deleted.
        rc - the filesystem-only ResourceCollection.
      • setIncludes

        public void setIncludes​(java.lang.String includes)
        Sets the set of include patterns. Patterns may be separated by a comma or a space.
        setIncludes in class MatchingTask
        includes - the string containing the include patterns
      • setExcludes

        public void setExcludes​(java.lang.String excludes)
        Sets the set of exclude patterns. Patterns may be separated by a comma or a space.
        setExcludes in class MatchingTask
        excludes - the string containing the exclude patterns
      • setDefaultexcludes

        public void setDefaultexcludes​(boolean useDefaultExcludes)
        Sets whether default exclusions should be used or not.
        setDefaultexcludes in class MatchingTask
        useDefaultExcludes - "true"|"on"|"yes" when default exclusions should be used, "false"|"off"|"no" when they shouldn't be used.
      • setIncludesfile

        public void setIncludesfile​( includesfile)
        Sets the name of the file containing the includes patterns.
        setIncludesfile in class MatchingTask
        includesfile - A string containing the filename to fetch the include patterns from.
      • setExcludesfile

        public void setExcludesfile​( excludesfile)
        Sets the name of the file containing the includes patterns.
        setExcludesfile in class MatchingTask
        excludesfile - A string containing the filename to fetch the include patterns from.
      • setCaseSensitive

        public void setCaseSensitive​(boolean isCaseSensitive)
        Sets case sensitivity of the file system
        setCaseSensitive in class MatchingTask
        isCaseSensitive - "true"|"on"|"yes" if file system is case sensitive, "false"|"off"|"no" when not.
      • setFollowSymlinks

        public void setFollowSymlinks​(boolean followSymlinks)
        Sets whether or not symbolic links should be followed.
        setFollowSymlinks in class MatchingTask
        followSymlinks - whether or not symbolic links should be followed
      • setRemoveNotFollowedSymlinks

        public void setRemoveNotFollowedSymlinks​(boolean b)
        Sets whether the symbolic links that have not been followed shall be removed (the links, not the locations they point at).
        b - boolean
        Ant 1.8.0
      • removeDir

        protected void removeDir​( d)
        Delete a directory
        d - the directory to delete
      • removeFiles

        protected void removeFiles​( d,
                                   java.lang.String[] files,
                                   java.lang.String[] dirs)
        remove an array of files in a directory, and a list of subdirectories which will only be deleted if 'includeEmpty' is true
        d - directory to work from
        files - array of files to delete; can be of zero length
        dirs - array of directories to delete; can of zero length