Class FileSetManager
- java.lang.Object
-
- org.apache.maven.shared.model.fileset.util.FileSetManager
-
public class FileSetManager extends java.lang.ObjectProvides operations for use with FileSet instances, such as retrieving the included/excluded files, deleting all matching entries, etc.- Version:
- $Id: FileSetManager.java 1721672 2015-12-25 13:18:36Z khmarbaise $
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String[]EMPTY_STRING_ARRAYprivate org.apache.maven.shared.io.logging.MessageHoldermessagesprivate booleanverbose
-
Constructor Summary
Constructors Constructor Description FileSetManager()Create a new manager instance with an empty messages.FileSetManager(org.apache.maven.plugin.logging.Log log)Create a new manager instance with the supplied log instance.FileSetManager(org.apache.maven.plugin.logging.Log log, boolean verbose)Create a new manager instance with the supplied log instance and flag for whether to output verbose messages.FileSetManager(org.codehaus.plexus.logging.Logger log)Create a new manager instance with the supplied log instance.FileSetManager(org.codehaus.plexus.logging.Logger log, boolean verbose)Create a new manager instance with the supplied log instance and flag for whether to output verbose messages.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleandelete(java.io.File f)Delete a filevoiddelete(FileSet fileSet)Delete the matching files and directories for the given file-set definition.voiddelete(FileSet fileSet, boolean throwsError)Delete the matching files and directories for the given file-set definition.private voidexcludeParentDirectoriesOfExcludedPaths(java.util.List<java.lang.String> excludedPaths, java.util.Set<java.lang.String> deletablePaths)Removes all parent directories of the already excluded files/directories from the given set of deletable directories.private java.util.Set<java.lang.String>findDeletableDirectories(FileSet fileSet)private java.util.Set<java.lang.String>findDeletableFiles(FileSet fileSet, java.util.Set<java.lang.String> deletableDirectories)private java.util.Set<java.lang.String>findDeletablePaths(FileSet fileSet)java.lang.String[]getExcludedDirectories(FileSet fileSet)Get all the directory names which have been excluded by the rules in this fileset.java.lang.String[]getExcludedFiles(FileSet fileSet)Get all the filenames which have been excluded by the rules in this fileset.java.lang.String[]getIncludedDirectories(FileSet fileSet)Get all the directory names which have been included by the rules in this fileset.java.lang.String[]getIncludedFiles(FileSet fileSet)Get all the filenames which have been included by the rules in this fileset.private booleanisSymlink(java.io.File file)java.util.Map<java.lang.String,java.lang.String>mapIncludedFiles(FileSet fileSet)private voidremoveDir(java.io.File dir, boolean followSymlinks, boolean throwsError, java.util.List<java.lang.String> warnMessages)Delete a directoryprivate org.apache.maven.shared.utils.io.DirectoryScannerscan(FileSet fileSet)
-
-
-
Constructor Detail
-
FileSetManager
public FileSetManager(org.apache.maven.plugin.logging.Log log, boolean verbose)Create a new manager instance with the supplied log instance and flag for whether to output verbose messages.- Parameters:
log- The mojo log instanceverbose- Whether to output verbose messages
-
FileSetManager
public FileSetManager(org.apache.maven.plugin.logging.Log log)
Create a new manager instance with the supplied log instance. Verbose flag is set to false.- Parameters:
log- The mojo log instance
-
FileSetManager
public FileSetManager(org.codehaus.plexus.logging.Logger log, boolean verbose)Create a new manager instance with the supplied log instance and flag for whether to output verbose messages.- Parameters:
log- The mojo log instanceverbose- Whether to output verbose messages
-
FileSetManager
public FileSetManager(org.codehaus.plexus.logging.Logger log)
Create a new manager instance with the supplied log instance. Verbose flag is set to false.- Parameters:
log- The mojo log instance
-
FileSetManager
public FileSetManager()
Create a new manager instance with an empty messages. Verbose flag is set to false.
-
-
Method Detail
-
mapIncludedFiles
public java.util.Map<java.lang.String,java.lang.String> mapIncludedFiles(FileSet fileSet) throws MapperException
- Parameters:
fileSet-FileSet- Returns:
- the included files as map
- Throws:
MapperException- if any- See Also:
getIncludedFiles(FileSet)
-
getIncludedFiles
public java.lang.String[] getIncludedFiles(FileSet fileSet)
Get all the filenames which have been included by the rules in this fileset.- Parameters:
fileSet- The fileset defining rules for inclusion/exclusion, and base directory.- Returns:
- the array of matching filenames, relative to the basedir of the file-set.
-
getIncludedDirectories
public java.lang.String[] getIncludedDirectories(FileSet fileSet)
Get all the directory names which have been included by the rules in this fileset.- Parameters:
fileSet- The fileset defining rules for inclusion/exclusion, and base directory.- Returns:
- the array of matching dirnames, relative to the basedir of the file-set.
-
getExcludedFiles
public java.lang.String[] getExcludedFiles(FileSet fileSet)
Get all the filenames which have been excluded by the rules in this fileset.- Parameters:
fileSet- The fileset defining rules for inclusion/exclusion, and base directory.- Returns:
- the array of non-matching filenames, relative to the basedir of the file-set.
-
getExcludedDirectories
public java.lang.String[] getExcludedDirectories(FileSet fileSet)
Get all the directory names which have been excluded by the rules in this fileset.- Parameters:
fileSet- The fileset defining rules for inclusion/exclusion, and base directory.- Returns:
- the array of non-matching dirnames, relative to the basedir of the file-set.
-
delete
public void delete(FileSet fileSet) throws java.io.IOException
Delete the matching files and directories for the given file-set definition.- Parameters:
fileSet- The file-set matching rules, along with search base directory- Throws:
java.io.IOException- If a matching file cannot be deleted
-
delete
public void delete(FileSet fileSet, boolean throwsError) throws java.io.IOException
Delete the matching files and directories for the given file-set definition.- Parameters:
fileSet- The file-set matching rules, along with search base directory.throwsError- Throw IOException when errors have occurred by deleting files or directories.- Throws:
java.io.IOException- If a matching file cannot be deleted andthrowsError=true, otherwise print warning messages.
-
isSymlink
private boolean isSymlink(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
findDeletablePaths
private java.util.Set<java.lang.String> findDeletablePaths(FileSet fileSet)
-
findDeletableDirectories
private java.util.Set<java.lang.String> findDeletableDirectories(FileSet fileSet)
-
findDeletableFiles
private java.util.Set<java.lang.String> findDeletableFiles(FileSet fileSet, java.util.Set<java.lang.String> deletableDirectories)
-
excludeParentDirectoriesOfExcludedPaths
private void excludeParentDirectoriesOfExcludedPaths(java.util.List<java.lang.String> excludedPaths, java.util.Set<java.lang.String> deletablePaths)Removes all parent directories of the already excluded files/directories from the given set of deletable directories. I.e. if "subdir/excluded.txt" should not be deleted, "subdir" should be excluded from deletion, too.- Parameters:
excludedPaths- The relative paths of the files/directories which are excluded from deletion, must not benull.deletablePaths- The relative paths to files/directories which are scheduled for deletion, must not benull.
-
removeDir
private void removeDir(java.io.File dir, boolean followSymlinks, boolean throwsError, java.util.List<java.lang.String> warnMessages) throws java.io.IOExceptionDelete a directory- Parameters:
dir- the directory to deletefollowSymlinks- whether to follow symbolic links, or simply delete the linkthrowsError- Throw IOException when errors have occurred by deleting files or directories.warnMessages- A list of warning messages used whenthrowsError=false.- Throws:
java.io.IOException- If a matching file cannot be deleted andthrowsError=true.
-
delete
private boolean delete(java.io.File f)
Delete a file- Parameters:
f- a file
-
scan
private org.apache.maven.shared.utils.io.DirectoryScanner scan(FileSet fileSet)
-
-