org.apache.tools.ant.taskdefs
Class Sync

java.lang.Object
  |
  +--org.apache.tools.ant.ProjectComponent
        |
        +--org.apache.tools.ant.Task
              |
              +--org.apache.tools.ant.taskdefs.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.
Version:
$Revision: 1.7.2.5 $

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
 
Constructor Summary
Sync()
           
 
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(java.io.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
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sync

public Sync()
Method Detail

init

public void init()
          throws BuildException
Description copied from class: Task
Called by the project to let the task initialize properly. The default implementation is a no-op.

Overrides:
init in class Task
Throws:
BuildException - if something goes wrong with the build

execute

public void execute()
             throws BuildException
Description copied from class: Task
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 class Task
Throws:
BuildException - if something goes wrong with the build

setTodir

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


setVerbose

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


setOverwrite

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


setIncludeEmptyDirs

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


setFailOnError

public void setFailOnError(boolean failonerror)
If false, note errors to the output but keep going.

Parameters:
failonerror - true or false

addFileset

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


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


Copyright © 2000-2004 Apache Software Foundation. All Rights Reserved.