@Component(role=IOUtil.class, hint="default") public class DefaultIOUtil extends org.codehaus.plexus.logging.AbstractLogEnabled implements IOUtil
Constructor and Description |
---|
DefaultIOUtil() |
Modifier and Type | Method and Description |
---|---|
void |
close(ZipFile closeable)
Silently closes the resource
|
void |
copyDirectoryStructure(File sourceDirectory,
File targetDirectory)
Copy directory structure from
sourceDirectory to targetDirectory . |
void |
copyFile(File sourceFile,
File targetFile) |
boolean |
copyFileToDirectoryIfNecessary(File sourceFile,
File targetDirectory)
Conditionally copy the file into the target directory.
|
void |
copyResources(File sourceDirectory,
File targetDirectory)
Copy the content of a directory to another one recursively.
|
void |
copyResources(URI uri,
ClassLoader classLoader,
File target)
Copy a resource from the given uri to
target file. |
void |
createArchive(File directory,
File archive) |
void |
deleteFile(File file)
Delete a file.
|
int |
deleteFiles(File directory,
FileFilter fileFilter) |
void |
makeDirectoryIfNecessary(File dir)
Create the given directory if it does not exist.
|
void |
removeDirectory(File dir)
Delete the specified directory.
|
void |
renameTo(File source,
File target)
Rename a file.
|
boolean |
shouldCopyFile(File sourceFile,
File targetFile) |
public void copyResources(File sourceDirectory, File targetDirectory) throws org.apache.maven.plugin.MojoExecutionException
copyResources
in interface IOUtil
sourceDirectory
- directory to copytargetDirectory
- where to copyorg.apache.maven.plugin.MojoExecutionException
- if could not perform operationpublic void copyFile(File sourceFile, File targetFile) throws org.apache.maven.plugin.MojoExecutionException
public void copyDirectoryStructure(File sourceDirectory, File targetDirectory) throws org.apache.maven.plugin.MojoExecutionException
sourceDirectory
to targetDirectory
.copyDirectoryStructure
in interface IOUtil
sourceDirectory
- source of copytargetDirectory
- target of copyorg.apache.maven.plugin.MojoExecutionException
- if could not perform operationpublic boolean shouldCopyFile(File sourceFile, File targetFile)
shouldCopyFile
in interface IOUtil
sourceFile
- source filetargetFile
- target filetrue
if source file should be copy to target locationpublic boolean copyFileToDirectoryIfNecessary(File sourceFile, File targetDirectory) throws org.apache.maven.plugin.MojoExecutionException
sourceFile
name.copyFileToDirectoryIfNecessary
in interface IOUtil
sourceFile
- source file to copytargetDirectory
- location of the target directory where to copy filetrue
when the file was copied, false
otherwise.org.apache.maven.plugin.MojoExecutionException
- if an error occurs attempting to copy the file.public void removeDirectory(File dir) throws org.apache.maven.plugin.MojoExecutionException
removeDirectory
in interface IOUtil
dir
- the directory to deleteorg.apache.maven.plugin.MojoExecutionException
- if could not delete directorypublic void makeDirectoryIfNecessary(File dir) throws org.apache.maven.plugin.MojoExecutionException
makeDirectoryIfNecessary
in interface IOUtil
dir
- the dir to create if it does not existorg.apache.maven.plugin.MojoExecutionException
- if could not create directorypublic int deleteFiles(File directory, FileFilter fileFilter) throws org.apache.maven.plugin.MojoExecutionException
deleteFiles
in interface IOUtil
directory
- location of directory where to delete some filesfileFilter
- filter to select files to deleteorg.apache.maven.plugin.MojoExecutionException
- if could not delete filespublic void deleteFile(File file) throws org.apache.maven.plugin.MojoExecutionException
deleteFile
in interface IOUtil
file
- the file to deleteorg.apache.maven.plugin.MojoExecutionException
- if could not delete filepublic void renameTo(File source, File target) throws org.apache.maven.plugin.MojoExecutionException
public void copyResources(URI uri, ClassLoader classLoader, File target) throws org.apache.maven.plugin.MojoExecutionException
target
file.
The resource can come from class-path is the scheme is classpath
, otherwise will try to get incoming
resource from the url obtained from the uri.copyResources
in interface IOUtil
uri
- uri to copyclassLoader
- classloader used to find resource in from classpahttarget
- where to copyorg.apache.maven.plugin.MojoExecutionException
- if something wrong happenpublic void close(ZipFile closeable)
public void createArchive(File directory, File archive) throws org.apache.maven.plugin.MojoExecutionException
createArchive
in interface IOUtil
org.apache.maven.plugin.MojoExecutionException
Copyright © 2005–2016 MojoHaus. All rights reserved.