Commons VFS includes several Ant tasks that can be used to create, delete, copy and move files of any supported type. The tasks are:
<v-copy>
.
Copies a set of source folders and files to a destination
folder.
<v-delete>
.
Deletes a file or folder.
<v-mkdir>
.
Creates a folder.
<v-move>
.
Moves a set of source folders and files to a destination
folder.
<v-sync>
.
Synchronises a destination folder with a set of source
folder and files.
All file name attributes support relative and absolute local file names, and absolute URI . File names are interpreted relative to the Ant project's base directory.
To use the Ant tasks, copy commons-vfs.jar and its
dependencies into the
$ANT_HOME/lib
directory,
and use the following in your Ant scipt to define the tasks:
Alternatively, you can provide an explicit classpath when you define the tasks:
You can also use antlib:
Notice: VFS tasks registered that way do not have te "v-" prefix.
If you migrate to antlib simply replace "v-" by e.g. "vfs:" or whatever
namespace you use.
Copies a set of files to a destination folder. Does not copy source files where the destination file exists and is newer than the source file. The copy task takes the following attributes:
Name | Description | Required |
---|---|---|
destdir | The destination folder. This folder is created if it does not exist. | One only |
destfile | The destination file. Can only be used if there is a single source file. | |
srcdir | The source folder. If used the includes and desdir attributes should be specified. | No |
includes | A comma or space separated list of files. The files are resolved in combination with the specified srcdir attribute. | Only if srcdir is specified. |
overwrite | Always copy files, ignoring the last-modified time of the destination file. | No, default is
false
.
|
preservelastmodified | Set the last-modified time of destination files to the same value as the source files. May not be supported by the destination file system. | No, default is
true
.
|
srcdirisbase | Set whether the source directory should be used as base directory. If set to true, the subdirectories of the specified directories will be copied as well. | No, default is
false
.
|
src | A source file or folder to copy. Copies all descendents of a folder. | No |
Moves a set of files to a destination folder. Has the same attributes and elements as the copy task and following attributes:
Name | Description | Required |
---|---|---|
tryRename | The destination folder. This folder is created if it does not exist. | No, default is
false
|
Synchronises a destination folder with a set of source files. Has the same attributes and elements as the copy task.
Deletes a file or folder. It takes the following attributes:
Name | Description | Required |
---|---|---|
file | The file or folder to delete. All descendents of the folder are deleted. | One only |
srcdir | The source folder. If used the includes attribute should be specified. | |
includes | A comma or space separated list of files. The files are resolved in combination with the specified srcdir attribute. | Only if srcdir is specified. |