Package org.apache.maven.plugins.clean
Class Cleaner
- java.lang.Object
-
- org.apache.maven.plugins.clean.Cleaner
-
class Cleaner extends java.lang.Object
Cleans directories.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Cleaner.BackgroundCleaner
private static interface
Cleaner.Logger
private static class
Cleaner.Result
(package private) static class
Cleaner.SpyInvocationHandler
-
Field Summary
Fields Modifier and Type Field Description private java.io.File
fastDir
private java.lang.String
fastMode
private static java.lang.String
LAST_DIRECTORY_TO_DELETE
private Cleaner.Logger
logDebug
private Cleaner.Logger
logInfo
private Cleaner.Logger
logVerbose
private Cleaner.Logger
logWarn
private static boolean
ON_WINDOWS
private org.apache.maven.execution.MavenSession
session
The maven session.
-
Constructor Summary
Constructors Constructor Description Cleaner(org.apache.maven.execution.MavenSession session, org.apache.maven.plugin.logging.Log log, boolean verbose, java.io.File fastDir, java.lang.String fastMode)
Creates a new cleaner.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private int
delete(java.io.File file, boolean failOnError, boolean retryOnError)
Deletes the specified file, directory.private Cleaner.Result
delete(java.io.File file, java.lang.String pathname, Selector selector, boolean followSymlinks, boolean failOnError, boolean retryOnError)
Deletes the specified file or directory.void
delete(java.io.File basedir, Selector selector, boolean followSymlinks, boolean failOnError, boolean retryOnError)
Deletes the specified directories and its contents.private boolean
fastDelete(java.io.File baseDirFile)
private boolean
isSymbolicLink(java.nio.file.Path path)
-
-
-
Field Detail
-
ON_WINDOWS
private static final boolean ON_WINDOWS
-
LAST_DIRECTORY_TO_DELETE
private static final java.lang.String LAST_DIRECTORY_TO_DELETE
-
session
private final org.apache.maven.execution.MavenSession session
The maven session. This is typically non-null in a real run, but it can be during unit tests.
-
logDebug
private final Cleaner.Logger logDebug
-
logInfo
private final Cleaner.Logger logInfo
-
logVerbose
private final Cleaner.Logger logVerbose
-
logWarn
private final Cleaner.Logger logWarn
-
fastDir
private final java.io.File fastDir
-
fastMode
private final java.lang.String fastMode
-
-
Constructor Detail
-
Cleaner
Cleaner(org.apache.maven.execution.MavenSession session, org.apache.maven.plugin.logging.Log log, boolean verbose, java.io.File fastDir, java.lang.String fastMode)
Creates a new cleaner.- Parameters:
log
- The logger to use, may benull
to disable logging.verbose
- Whether to perform verbose logging.fastMode
- The fast deletion mode
-
-
Method Detail
-
delete
public void delete(java.io.File basedir, Selector selector, boolean followSymlinks, boolean failOnError, boolean retryOnError) throws java.io.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 benull
to 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:
java.io.IOException
- If a file/directory could not be deleted andfailOnError
istrue
.
-
fastDelete
private boolean fastDelete(java.io.File baseDirFile)
-
delete
private Cleaner.Result delete(java.io.File file, java.lang.String pathname, Selector selector, boolean followSymlinks, boolean failOnError, boolean retryOnError) throws java.io.IOException
Deletes the specified file or directory.- Parameters:
file
- The file/directory to delete, must not benull
. IffollowSymlinks
isfalse
, 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 benull
to 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:
java.io.IOException
- If a file/directory could not be deleted andfailOnError
istrue
.
-
isSymbolicLink
private boolean isSymbolicLink(java.nio.file.Path path) throws java.io.IOException
- Throws:
java.io.IOException
-
delete
private int delete(java.io.File file, boolean failOnError, boolean retryOnError) throws java.io.IOException
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:
0
if the file was deleted,1
otherwise.- Throws:
java.io.IOException
- If a file/directory could not be deleted andfailOnError
istrue
.
-
-