org.apache.maven.shared.model.fileset.util
Class FileSetManager

java.lang.Object
  extended by org.apache.maven.shared.model.fileset.util.FileSetManager

public class FileSetManager
extends java.lang.Object

Provides operations for use with FileSet instances, such as retrieving the included/excluded files, deleting all matching entries, etc.

Author:
jdcasey

Field Summary
private static int DELETE_RETRY_SLEEP_MILLIS
           
private static java.lang.String[] EMPTY_STRING_ARRAY
           
private  org.apache.maven.shared.io.logging.MessageHolder messages
           
private  boolean verbose
           
 
Constructor Summary
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
private  boolean delete(java.io.File f)
          Accommodate Windows bug encountered in both Sun and IBM JDKs.
 void delete(FileSet fileSet)
          Delete the matching files and directories for the given file-set definition.
private  java.util.Set findDeletableDirectories(FileSet fileSet)
           
private  java.util.Set findDeletableFiles(FileSet fileSet, java.util.Set deletableDirectories)
           
private  java.util.Set 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  boolean isSymlink(java.io.File file)
           
 java.util.Map mapIncludedFiles(FileSet fileSet)
           
private  void removeDir(java.io.File dir, boolean followSymlinks)
          Delete a directory
private  org.codehaus.plexus.util.DirectoryScanner scan(FileSet fileSet)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DELETE_RETRY_SLEEP_MILLIS

private static final int DELETE_RETRY_SLEEP_MILLIS
See Also:
Constant Field Values

EMPTY_STRING_ARRAY

private static final java.lang.String[] EMPTY_STRING_ARRAY

verbose

private final boolean verbose

messages

private org.apache.maven.shared.io.logging.MessageHolder messages
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 instance
verbose - 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 instance
verbose - 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.

Parameters:
log - The mojo log instance
Method Detail

mapIncludedFiles

public java.util.Map mapIncludedFiles(FileSet fileSet)
                               throws MapperException
Throws:
MapperException

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

isSymlink

private boolean isSymlink(java.io.File file)
                   throws java.io.IOException
Throws:
java.io.IOException

findDeletablePaths

private java.util.Set findDeletablePaths(FileSet fileSet)

findDeletableDirectories

private java.util.Set findDeletableDirectories(FileSet fileSet)

findDeletableFiles

private java.util.Set findDeletableFiles(FileSet fileSet,
                                         java.util.Set deletableDirectories)

removeDir

private void removeDir(java.io.File dir,
                       boolean followSymlinks)
                throws java.io.IOException
Delete a directory

Parameters:
dir - the directory to delete
followSymlinks - whether to follow symbolic links, or simply delete the link
Throws:
java.io.IOException

delete

private boolean delete(java.io.File f)
                throws java.io.IOException
Accommodate Windows bug encountered in both Sun and IBM JDKs. Others possible. If the delete does not work, call System.gc(), wait a little and try again.

Parameters:
f -
Throws:
java.io.IOException - if any

scan

private org.codehaus.plexus.util.DirectoryScanner scan(FileSet fileSet)