Package org.apache.tools.ant.taskdefs
Class Move
- java.lang.Object
- 
- org.apache.tools.ant.ProjectComponent
- 
- org.apache.tools.ant.Task
- 
- org.apache.tools.ant.taskdefs.Copy
- 
- org.apache.tools.ant.taskdefs.Move
 
 
 
 
- 
- All Implemented Interfaces:
- java.lang.Cloneable
 
 public class Move extends Copy Moves a file or directory to a new file or directory. By default, the destination file is overwritten if it already exists. When overwrite is turned off, then files are only moved if the source file is newer than the destination file, or when the destination file does not exist.Source files and directories are only deleted when the file or directory has been copied to the destination successfully. Filtering also works. This implementation is based on Arnout Kuiper's initial design document, the following mailing list discussions, and the copyfile/copydir tasks. - Since:
- Ant 1.2
 
- 
- 
Field Summary- 
Fields inherited from class org.apache.tools.ant.taskdefs.CopycompleteDirMap, destDir, destFile, dirCopyMap, failonerror, file, fileCopyMap, filesets, fileUtils, filtering, flatten, forceOverwrite, includeEmpty, mapperElement, preserveLastModified, rcs, verbosity
 - 
Fields inherited from class org.apache.tools.ant.ProjectComponentdescription, location, project
 
- 
 - 
Constructor SummaryConstructors Constructor Description Move()Constructor of object.
 - 
Method SummaryModifier and Type Method Description protected voiddeleteDir(java.io.File d)Go and delete the directory tree.protected voiddeleteDir(java.io.File d, boolean deleteFiles)Go and delete the directory tree.protected voiddoFileOperations()Override copy's doFileOperations to move the files instead of copying them.protected booleanokToDelete(java.io.File d)Its only ok to delete a directory tree if there are no files in it.protected booleanrenameFile(java.io.File sourceFile, java.io.File destFile, boolean filtering, boolean overwrite)Attempts to rename a file from a source to a destination.voidsetPerformGcOnFailedDelete(boolean b)Whether to perform a garbage collection before retrying a failed delete.protected voidvalidateAttributes()Ensure we have a consistent and legal set of attributes, and set any internal flags necessary based on different combinations of attributes.- 
Methods inherited from class org.apache.tools.ant.taskdefs.Copyadd, add, addFileset, buildMap, buildMap, createFilterChain, createFilterSet, createMapper, doResourceOperations, execute, getEncoding, getFileUtils, getFilterChains, getFilterSets, getForce, getOutputEncoding, getPreserveLastModified, isEnableMultipleMapping, scan, scan, setEnableMultipleMappings, setEncoding, setFailOnError, setFile, setFiltering, setFlatten, setForce, setGranularity, setIncludeEmptyDirs, setOutputEncoding, setOverwrite, setPreserveLastModified, setPreserveLastModified, setQuiet, setTodir, setTofile, setVerbose, supportsNonFileResources
 - 
Methods inherited from class org.apache.tools.ant.TaskbindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 - 
Methods inherited from class org.apache.tools.ant.ProjectComponentclone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
- 
 
- 
- 
- 
Method Detail- 
setPerformGcOnFailedDeletepublic void setPerformGcOnFailedDelete(boolean b) Whether to perform a garbage collection before retrying a failed delete.This may be required on Windows (where it is set to true by default) but also on other operating systems, for example when deleting directories from an NFS share. - Parameters:
- b- boolean
- Since:
- Ant 1.8.3
 
 - 
validateAttributesprotected void validateAttributes() throws BuildExceptionEnsure we have a consistent and legal set of attributes, and set any internal flags necessary based on different combinations of attributes..- Overrides:
- validateAttributesin class- Copy
- Throws:
- BuildException- if an error occurs.
 
 - 
doFileOperationsprotected void doFileOperations() Override copy's doFileOperations to move the files instead of copying them.- Overrides:
- doFileOperationsin class- Copy
 
 - 
okToDeleteprotected boolean okToDelete(java.io.File d) Its only ok to delete a directory tree if there are no files in it.- Parameters:
- d- the directory to check
- Returns:
- true if a deletion can go ahead
 
 - 
deleteDirprotected void deleteDir(java.io.File d) Go and delete the directory tree.- Parameters:
- d- the directory to delete
 
 - 
deleteDirprotected void deleteDir(java.io.File d, boolean deleteFiles)Go and delete the directory tree.- Parameters:
- d- the directory to delete
- deleteFiles- whether to delete files
 
 - 
renameFileprotected boolean renameFile(java.io.File sourceFile, java.io.File destFile, boolean filtering, boolean overwrite) throws java.io.IOException, BuildExceptionAttempts to rename a file from a source to a destination. If overwrite is set to true, this method overwrites existing file even if the destination file is newer. Otherwise, the source file is renamed only if the destination file is older than it. Method then checks if token filtering is used. If it is, this method returns false assuming it is the responsibility to the copyFile method.- Parameters:
- sourceFile- the file to rename
- destFile- the destination file
- filtering- if true, filtering is in operation, file will be copied/deleted instead of renamed
- overwrite- if true force overwrite even if destination file is newer than source file
- Returns:
- true if the file was renamed
- Throws:
- java.io.IOException- if an error occurs
- BuildException- if an error occurs
 
 
- 
 
-