Package org.apache.maven.plugins.clean
Class Cleaner
- java.lang.Object
-
- org.apache.maven.plugins.clean.Cleaner
-
class Cleaner extends java.lang.ObjectCleans directories.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classCleaner.BackgroundCleanerprivate static classCleaner.Result(package private) static classCleaner.SpyInvocationHandler
-
Field Summary
Fields Modifier and Type Field Description private java.nio.file.PathfastDirprivate java.lang.StringfastModeprivate booleanforceWhether to force the deletion of read-only files.private static java.lang.StringLAST_DIRECTORY_TO_DELETEprivate org.apache.maven.plugin.logging.Loglogprivate static booleanON_WINDOWSprivate org.apache.maven.execution.MavenSessionsessionThe maven session.private booleanverbose
-
Constructor Summary
Constructors Constructor Description Cleaner(org.apache.maven.execution.MavenSession session, org.apache.maven.plugin.logging.Log log, boolean verbose, java.nio.file.Path fastDir, java.lang.String fastMode, boolean force)Creates a new cleaner.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.io.IOExceptiondelete(java.nio.file.Path file)private intdelete(java.nio.file.Path file, boolean failOnError, boolean retryOnError)Deletes the specified file, directory.private Cleaner.Resultdelete(java.nio.file.Path file, java.lang.String pathname, Selector selector, boolean followSymlinks, boolean failOnError, boolean retryOnError)Deletes the specified file or directory.voiddelete(java.nio.file.Path basedir, Selector selector, boolean followSymlinks, boolean failOnError, boolean retryOnError)Deletes the specified directories and its contents.private booleanfastDelete(java.nio.file.Path baseDir)private booleanisSymbolicLink(java.nio.file.Path path)private static java.nio.file.PathsetWritable(java.nio.file.Path file)Makes the given file or directory writable.
-
-
-
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.
-
fastDir
private final java.nio.file.Path fastDir
-
fastMode
private final java.lang.String fastMode
-
verbose
private final boolean verbose
-
log
private org.apache.maven.plugin.logging.Log log
-
force
private final boolean force
Whether to force the deletion of read-only files. Note that on Linux,Files.delete(Path)andFiles.deleteIfExists(Path)delete read-only files but throwAccessDeniedExceptionif the directory containing the file is read-only.
-
-
Constructor Detail
-
Cleaner
Cleaner(org.apache.maven.execution.MavenSession session, org.apache.maven.plugin.logging.Log log, boolean verbose, java.nio.file.Path fastDir, java.lang.String fastMode, boolean force)Creates a new cleaner.- Parameters:
session- The Maven session to be used.log- The logger to use.verbose- Whether to perform verbose logging.fastDir- The explicit configured directory or to be deleted in fast mode.fastMode- The fast deletion mode.force- whether to force the deletion of read-only files
-
-
Method Detail
-
delete
public void delete(java.nio.file.Path basedir, Selector selector, boolean followSymlinks, boolean failOnError, boolean retryOnError) throws java.io.IOExceptionDeletes 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:
java.io.IOException- If a file/directory could not be deleted andfailOnErroristrue.
-
fastDelete
private boolean fastDelete(java.nio.file.Path baseDir)
-
delete
private Cleaner.Result delete(java.nio.file.Path 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. 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:
java.io.IOException- If a file/directory could not be deleted andfailOnErroristrue.
-
isSymbolicLink
private boolean isSymbolicLink(java.nio.file.Path path) throws java.io.IOException- Throws:
java.io.IOException
-
setWritable
private static java.nio.file.Path setWritable(java.nio.file.Path file) throws java.io.IOExceptionMakes the given file or directory writable. If the file is already writable, then this method tries to make the parent directory writable.- Parameters:
file- the path to the file or directory to make writable, ornullif none- Returns:
- the root path which has been made writable, or
nullif none - Throws:
java.io.IOException
-
delete
private int delete(java.nio.file.Path file, boolean failOnError, boolean retryOnError) throws java.io.IOExceptionDeletes 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:
java.io.IOException- If a file/directory could not be deleted andfailOnErroristrue.
-
delete
private static java.io.IOException delete(java.nio.file.Path file)
-
-