ANT Tasks – Move


Apache Ant Tasks – Move



”;


Description

Move task moves a file to a new file or directory, or collections of files to a new 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.

Properties




















Sr.No Attributes & Description
1

File

The file or directory to move.

2

Preservelastmodified

Give the moved files the same last modified time as the original source files.

3

Tofile

The file to move to.

4

Todir

The directory to move to.

5

Overwrite

Overwrite existing files even if the destination files are newer.

6

Force

Overwrite read-only destination files.

7

Filtering

Indicates whether token filtering should take place during the move.

8

Flatten

Ignore directory structure of source directory, copy all files into a single directory, specified by the todir attribute.

9

IncludeEmptyDirs

Copy empty directories included with the nested FileSet(s).

10

Failonerror

If false, log a warning message, but do not stop the build, when the file to copy does not exist or one of the nested filesets points to a directory that doesn”t exist or an error occurs while moving.

11

Quiet

If true and failonerror is false, then do not log a warning message when the file to copy does not exist or one of the nested filesets points to a directory that doesn”t exist or an error occurs while copying.

12

Verbose

Log the files that are being moved.

13

Encoding

The encoding to assume when filter-copying the files.

14

Outputencoding

The encoding to use when writing the files.

15

Enablemultiplemappings

If true the task will process to all the mappings for a given source path. If false the task will only process the first file or directory. This attribute is only relevant if there is a mapper subelement.

16

Granularity

The number of milliseconds leeway to give before deciding a file is out of date. This is needed because not every file system supports tracking the last modified time to the millisecond level. This can also be useful if source and target files live on separate machines with clocks being out of sync.

17

performGCOnFailedDelete

If Ant fails to delete a file or directory it will retry the operation once. If this flag is set to true it will perform a garbage collection before retrying the delete. Setting this flag to true is known to resolve some problems on Windows (where it defaults to true) but also for directory trees residing on an NFS share.

Example

Usage

Create build.xml with the following content −


<?xml version="1.0"?>
<project name="TutorialPoint" default="info">
   <target name="info">
      <move file="message.txt" tofile="message.txt.moved"/>
   </target>
</project>

Output

Running Ant on the above build file produces the following output −


F:tutorialspointant>ant
Buildfile: F:tutorialspointantbuild.xml

info:
   [move] Moving 1 file to F:tutorialspointant

BUILD SUCCESSFUL
Total time: 0 seconds

Advertisements

”;

Leave a Reply

Your email address will not be published. Required fields are marked *