org.apache.tools.ant.taskdefs

Class Sync


public class Sync
extends Task

Synchronize a local target directory from the files defined in one or more filesets.

Uses a <copy> task internally, but forbidding the use of mappers and filter chains. Files of the destination directory not present in any of the source fileset are removed.

Since:
Ant 1.6 revised by Dan Armbrust to remove orphaned directories.

Nested Class Summary

static class
Sync.MyCopy
Subclass Copy in order to access it's file/dir maps.

Field Summary

Fields inherited from class org.apache.tools.ant.Task

description, location, target, taskName, taskType, wrapper

Fields inherited from class org.apache.tools.ant.ProjectComponent

project

Method Summary

void
addFileset(FileSet set)
Adds a set of files to copy.
void
execute()
Called by the project to let the task do its work.
void
init()
Called by the project to let the task initialize properly.
void
setFailOnError(boolean failonerror)
If false, note errors to the output but keep going.
void
setGranularity(long granularity)
The number of milliseconds leeway to give before deciding a target is out of date.
void
setIncludeEmptyDirs(boolean includeEmpty)
Used to copy empty directories.
void
setOverwrite(boolean overwrite)
Overwrite any existing destination file(s).
void
setTodir(File destDir)
Sets the destination directory.
void
setVerbose(boolean verbose)
Used to force listing of all names of copied files.

Methods inherited from class org.apache.tools.ant.Task

execute, getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType

Methods inherited from class org.apache.tools.ant.ProjectComponent

getProject, log, log, setProject

Method Details

addFileset

public void addFileset(FileSet set)
Adds a set of files to copy.

execute

public void execute()
            throws BuildException
Called by the project to let the task do its work. This method may be called more than once, if the task is invoked more than once. For example, if target1 and target2 both depend on target3, then running "ant target1 target2" will run all tasks in target3 twice.
Overrides:
execute in interface Task
Throws:
BuildException - if something goes wrong with the build

init

public void init()
            throws BuildException
Called by the project to let the task initialize properly. The default implementation is a no-op.
Overrides:
init in interface Task
Throws:
BuildException - if something goes wrong with the build

setFailOnError

public void setFailOnError(boolean failonerror)
If false, note errors to the output but keep going.
Parameters:
failonerror - true or false

setGranularity

public void setGranularity(long granularity)
The number of milliseconds leeway to give before deciding a target is out of date.

Default is 0 milliseconds, or 2 seconds on DOS systems.

Since:
Ant 1.6.2

setIncludeEmptyDirs

public void setIncludeEmptyDirs(boolean includeEmpty)
Used to copy empty directories.

setOverwrite

public void setOverwrite(boolean overwrite)
Overwrite any existing destination file(s).

setTodir

public void setTodir(File destDir)
Sets the destination directory.

setVerbose

public void setVerbose(boolean verbose)
Used to force listing of all names of copied files.

Copyright B) 2000-2006 Apache Software Foundation. All Rights Reserved.