org.jboss.maven.util.file
Class DirectoryCopier

java.lang.Object
  extended by org.jboss.maven.util.file.DirectoryCopier

public class DirectoryCopier
extends Object

Copies a directory with its structure intact. Optionally allows defining includes and/or excludes. Internally uses a DirectoryScanner, mainly to ensure we filter out "standard excludes" (like SCM dirs) but also to apply any optional includes and/or excludes.

Author:
Steve Ebersole

Constructor Summary
DirectoryCopier(File sourceDirectory)
          Instantiates a directory copier over the given source directory.
 
Method Summary
static void copyFileIfModified(File source, File destination)
          Copies the source file to the destination file.
 void copyTo(File targetDirectory)
          Copy contents of the source directory to the given target directory.
 void copyTo(File targetDirectory, String[] includes, String[] excludes)
          Copy contents of the source directory to the given target directory.
 File getSourceDirectory()
          Retrieve the source directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectoryCopier

public DirectoryCopier(File sourceDirectory)
Instantiates a directory copier over the given source directory.

Parameters:
sourceDirectory - The directory from which to copy.
Method Detail

getSourceDirectory

public File getSourceDirectory()
Retrieve the source directory.

Returns:
The source directory.

copyTo

public void copyTo(File targetDirectory)
            throws IOException
Copy contents of the source directory to the given target directory.

Same as copy(targetDirectory,null,null)

Parameters:
targetDirectory - The directory to which to copy the content
Throws:
IOException - Indicates a problem performing the copy.

copyTo

public void copyTo(File targetDirectory,
                   String[] includes,
                   String[] excludes)
            throws IOException
Copy contents of the source directory to the given target directory.

NOTE: the copier copies all content to the target directory except for

Parameters:
targetDirectory - The directory to which to copy the matching content
includes - Explicit inclusion match filename patterns.
excludes - Explicit exclusion match filename patterns.
Throws:
IOException - Indicates a problem performing the copy.

copyFileIfModified

public static void copyFileIfModified(File source,
                                      File destination)
                               throws IOException
Copies the source file to the destination file.

Parameters:
source - The file to be copied
destination - The file to which to copy the source.
Throws:
IOException - Indicates a problem performing the copy.


Copyright © 2009 JBoss, a division of Red Hat, Inc. All Rights Reserved.