Package org.apache.maven.plugins.clean
Class Cleaner
java.lang.Object
org.apache.maven.plugins.clean.Cleaner
Cleans directories.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static interfaceprivate static class(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Fileprivate final Stringprivate static final Stringprivate final Cleaner.Loggerprivate final Cleaner.Loggerprivate final Cleaner.Loggerprivate final Cleaner.Loggerprivate static final booleanprivate final org.apache.maven.execution.MavenSessionThe maven session. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate intDeletes the specified file, directory.private Cleaner.Resultdelete(File file, String pathname, Selector selector, boolean followSymlinks, boolean failOnError, boolean retryOnError) Deletes the specified file or directory.voiddelete(File basedir, Selector selector, boolean followSymlinks, boolean failOnError, boolean retryOnError) Deletes the specified directories and its contents.private booleanfastDelete(File baseDirFile) private booleanisSymbolicLink(Path path)
-
Field Details
-
ON_WINDOWS
private static final boolean ON_WINDOWS -
LAST_DIRECTORY_TO_DELETE
-
session
private final org.apache.maven.execution.MavenSession sessionThe maven session. This is typically non-null in a real run, but it can be during unit tests. -
logDebug
-
logInfo
-
logVerbose
-
logWarn
-
fastDir
-
fastMode
-
-
Constructor Details
-
Cleaner
Cleaner(org.apache.maven.execution.MavenSession session, org.apache.maven.plugin.logging.Log log, boolean verbose, File fastDir, String fastMode) Creates a new cleaner.- Parameters:
log- The logger to use, may benullto disable logging.verbose- Whether to perform verbose logging.fastMode- The fast deletion mode
-
-
Method Details
-
delete
public void delete(File basedir, Selector selector, boolean followSymlinks, boolean failOnError, boolean retryOnError) throws IOException Deletes the specified directories and its contents.- Parameters:
basedir- The directory to delete, must not benull. Non-existing directories will be silently ignored.selector- The selector used to determine what contents to delete, may benullto delete everything.followSymlinks- Whether to follow symlinks.failOnError- Whether to abort with an exception in case a selected file/directory could not be deleted.retryOnError- Whether to undertake additional delete attempts in case the first attempt failed.- Throws:
IOException- If a file/directory could not be deleted andfailOnErroristrue.
-
fastDelete
-
delete
private Cleaner.Result delete(File file, String pathname, Selector selector, boolean followSymlinks, boolean failOnError, boolean retryOnError) throws IOException Deletes the specified file or directory.- Parameters:
file- The file/directory to delete, must not benull. IffollowSymlinksisfalse, it is assumed that the parent file is canonical.pathname- The relative pathname of the file, usingFile.separatorChar, must not benull.selector- The selector used to determine what contents to delete, may benullto delete everything.followSymlinks- Whether to follow symlinks.failOnError- Whether to abort with an exception in case a selected file/directory could not be deleted.retryOnError- Whether to undertake additional delete attempts in case the first attempt failed.- Returns:
- The result of the cleaning, never
null. - Throws:
IOException- If a file/directory could not be deleted andfailOnErroristrue.
-
isSymbolicLink
- Throws:
IOException
-
delete
Deletes the specified file, directory. If the path denotes a symlink, only the link is removed, its target is left untouched.- Parameters:
file- The file/directory to delete, must not benull.failOnError- Whether to abort with an exception in case the file/directory could not be deleted.retryOnError- Whether to undertake additional delete attempts in case the first attempt failed.- Returns:
0if the file was deleted,1otherwise.- Throws:
IOException- If a file/directory could not be deleted andfailOnErroristrue.
-