Move and/or rename one or several files and/or directories to a directory.
| Package: | org.schmant.task.base |
| Category: | I/O tasks |
| Since: | 0.5 |
| EntityFS-aware? | Yes |
| Implements: | ActionTaskFactory
GeneratorTaskFactory ProcessTaskFactory |
| See also: | RecursiveActionTF
RecursiveProcessTF |
Description
Move and/or rename one or several files and/or directories.
If the target is a directory all source entities are moved into it. If only one file or directory should be moved and also renamed, the target can be a nonexisting FutureEntity. If several entities should be moved and renamed, use a FutureEntityStrategy as target.
Often it is easier to call
Entities.move directly. This can be used if a build script wants to schedule
a task for moving an entity that has not been created yet, or together with a
RecursiveActionTF to move files recursively.
Required properties
Properties
| configurators | top |
A collection of Configurator:s. Configurator:s are used to configure a task right before it is run in a TaskExecutor with properties that are not available until all of the task's dependencies have been run.
Build scripts that don't use TaskExecutor:s don't have to use Configurator:s.
- Setter method:
-
addConfigurator(Configurator cf)
where:
cf– A configurator.
Add one configurator. - Setter method:
-
addConfigurators(Collection<? extends Configurator> c)
where:
c– A collection of configurators.
Add a collection of configurators.
| logFooter | top |
The message that is logged to info level
after the task has been successfully run.
- Setter method:
-
setLogFooter(java.lang.String s)
where:
s– The footer message.
- Default value:
- Empty (no footer message is logged.)
| logHeader | top |
The message that is logged to info level
before the task is run.
- Setter method:
-
setLogHeader(java.lang.String s)
where:
s– The header message.
- Default value:
- A task class specific message.
| overwrite | top |
If an entity already exists in the target location, should it be
overwritten? If false, the task throws an error instead.
- Setter method:
-
setOverwrite(boolean b)
where:
b– Should an existing entity be overwritten?
- Default value:
false(existing entities are not overwritten).- See also:
- target
| sources (required) | top |
A collection of files and/or directories to move to the target.
- Setter method:
-
setSource(java.lang.Object o)
where:
o– The source. Interpreted byArgumentInterpreter.getReadWriteEntity(java.lang.Object).
Set one source and discard previously set sources. - Setter method:
-
addSource(java.lang.Object o)
where:
o– The source. Interpreted byArgumentInterpreter.getReadWriteEntity(java.lang.Object).
Add one source. - Setter method:
-
addSources(Collection<?> c)
where:
c– A collection of sources.
Add a collection of sources.
| target (required) | top |
The target directory, future entity or future entity strategy.
- Setter method:
-
setTarget(java.lang.Object o)
where:
o– The target directory or future entity. Interpreted byArgumentInterpreter.getFutureEntity(java.lang.Object,java.lang.Object).
Examples
See RecursiveProcessTF for an example of how files in a directory hierarchy can be moved and renamed.Example 1
Move all Java files in the directory hierarchy under
d to the jDir directory.
addSource(new DirectoryAndFilter(d,
new EFileNameExtensionFilter("java"))).
setTaskFactory(
new MoveTF().
setTarget(jDir)).run();
Example 2
Move all Java files in the directory hierarchy under
d to a directory hierarchy under jDir.
The difference between this example and the previous example is that this
example uses a RecursiveProcessTF where the previous example used a
RecursiveActionTF. When using a RecursiveProcessTF, all processed
objects get their individual target location decided by the
targetStrategy in use.
addSource(new DirectoryAndFilter(d,
new EFileNameExtensionFilter("java"))).
setTarget(jDir).
setTaskFactory(
new MoveTF()).run();
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.