Copy files and directories recursively.
Task package: | org.schmant.task.base |
Java package: | org.schmant.task.io |
Category: | I/O tasks |
Since: | 0.5 |
EntityFS-aware? | Yes* |
Implements: | ActionTaskFactory GeneratorTaskFactory ProcessTaskFactory |
See also: | CopyTF RecursiveProcessTF |
Description:
Copy the contents of a set of directories (or views) recursively. The directory hierarchies from the source directories are merged and preserved at the target location.
This task is a convenient alternative to using RecursiveProcessTF together with CopyTF.
Required properties
Properties
logFooter | top |
The message that is logged to info
level
after the task has been successfully run.
- Setter method:
setLogFooter(String s)
parameters:s
– The footer message.- Default value:
- Empty (no footer message is logged.)
- See also:
- logHeader
logHeader | top |
The message that is logged to info
level
before the task is run.
- Setter method:
setLogHeader(String s)
parameters:s
– The header message.- Default value:
- A task class specific message.
- See also:
- logFooter
overwrite | top |
If there exists an entity with the same name as the entity being copied in the target directory, should that entity be overwritten? If not, the source entity is not copied.
- Setter method:
setOverwrite(boolean b)
parameters:b
– Should existing entities be overwritten?- Default value:
false
reportLevel | top |
This property is used to change the Report level for all task created by this task factory. The report level is changed for the thread running the task when the it is run, and is restored to its previous level when the it is done.
- Setter method:
setReportLevel(Level l)
Set the report levelparameters:l
– The new report level.
sources (required) | top |
A collection of source directories to copy files and directories from.
There are two ways that EntityFilter:s can be used to exclude files or directories from being copied:
- Using a DirectoryView as source: This task will only copy files and directories that match the view's filter. Furthermore, it will only recurse down into child directories that match the filter.
- Using a DirectoryAndFilter as source: This task will only copy files and directories that match the view's filter. It will however recurse down into all child directories of a processed directory. If an entity is copied to a target location that does not have a parent directory (i.e. the copied entity's parent directory did not pass the filter), all neccessary parent directories are created automatically.
See the examples below.
- Setter method:
addSource(Object o)
Add one or several sources.parameters:o
– A source object or an array or collection of source objects.
Interpreted byInterpretAsReadOnlyDirectoryStrategy
.- Setter method:
addSources(Object o)
Add one or several sources.parameters:o
– A source object or an array or collection of source objects.
Interpreted byInterpretAsReadOnlyDirectoryStrategy
.- Setter method:
clearSources()
Discard all sources.- Setter method:
setSource(Object o)
Set one or several sources and discard previously set sources.parameters:o
– A source object or an array or collection of source objects.
Interpreted byInterpretAsReadOnlyDirectoryStrategy
.- Setter method:
setSources(Object o)
Set one or several sources and discard previously set sources.parameters:o
– A source object or an array or collection of source objects.
Interpreted byInterpretAsReadOnlyDirectoryStrategy
.
target (required) | top |
The target directory.
- Setter method:
setTarget(Object o)
parameters:
traceLogging | top |
If trace logging is enabled for a task, it reports its configuration before it is run.
Trace logging may also be enabled globally for all tasks by calling TraceMode.setTraceMode(boolean).
- Setter method:
setTraceLogging(boolean b)
Enable or disable trace logging.parameters:b
– Enable trace logging?
Examples
Example 1
Copy all files and subdirectories of d1
to d2
.
Example 2
Copy all XML files in d1
to
d2
. Note that this do not copy the contents of any of d1
's
subdirectories since the directories in d1
are made invisible by
the view filter.
Example 3
Copy all XML files in d1
:s directory
hierarchy to a directory hierarchy under d2
. Note that his copies
all the directories in d1
's hierarchy, even those that don't
contain any XML files.
Example 4
Copy all XML files in d1
:s directory hierarchy to a directory
hierarchy under d2
. This does not create any directories at the target
location that don't contain any XML files (or subdirectories with XML files).
Example 5
Copy all XML files in d1
:s directory hierarchy to a directory
hierarchy under d2
. Don't copy directories that don't contain any
XML files. (This example does exactly the same as the previous example.)
* An EntityFS-aware task is implemented using EntityFS. This means that it uses the filter settings of DirectoryView:s and also that it often can work with other file system implementations than File-based, such as the RAM file system.