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.
| Modifier and Type | Class and Description |
|---|---|
| public static class | Sync.
Subclass Copy in order to access it's file/dir maps. |
| public static class | Sync.
Inner class used to hold exclude patterns and selectors to save stuff that happens to live in the target directory but should not get removed. |
| Modifier and Type | Field and Description |
|---|---|
| private Sync. | |
| private Resources | |
| private Sync. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | addPreserveInTarget(Sync.
a preserveintarget nested element sA container for patterns and selectors that can be used to specify files that should be kept in the target even if they are not present in any source directory. |
| private static void | |
| private void | |
| public void | |
| private Boolean | getExplicitPreserveEmptyDirs()
The value of preserveTarget's preserveEmptyDirs attribute if specified and preserveTarget has been used in the first place. |
| public void | |
| private void | |
| private int | Returns: the number of empty directories actually removed.the root directory to scan for empty directories. dir, boolean whether to remove the root directory
itself if it becomes empty. removeIfEmpty, Set<File> directories matched by
syncTarget preservedEmptyDirectories)Removes all empty directories from a directory. |
| private int | Returns: the number of empty directories actually removed.directories matched by
syncTarget preservedEmptyDirectories)Removes all empty directories preserved by preserveInTarget in the preserveEmptyDirs == FALSE case. |
| private int[] | Returns: the number of orphaned files and directories actually removed. Position 0 of the array is the number of orphaned directories. Position 1 of the array is the number or orphaned files.the table of all non-orphan nonOrphans, File Files.the initial file or directory to scan or test. toDir, Set<File> will be filled with the directories
matched by preserveInTarget - if any. Will not be
filled unless preserveEmptyDirs and includeEmptyDirs
conflict. preservedDirectories)Removes all files and folders not found as keys of a table (used as a set!). |
| public void | |
| public void | setGranularity(long
a granularity)long valueThe number of milliseconds leeway to give before deciding a target is out of date. |
| public void | setIncludeEmptyDirs(boolean
If true copy empty directories. includeEmpty)Used to copy empty directories. |
| public void | setOverwrite(boolean
if true overwrite any existing destination file(s). overwrite)Overwrite any existing destination file(s). |
| public void | |
| public void | setVerbose(boolean
if true force listing of all names of copied files. verbose)Used to force listing of all names of copied files. |
| myCopy | back to summary |
|---|---|
| private Sync. | |
| resources | back to summary |
|---|---|
| private Resources resources | |
| syncTarget | back to summary |
|---|---|
| private Sync. | |
| Sync | back to summary |
|---|---|
| public Sync() | |
| add | back to summary |
|---|---|
| public void add(ResourceCollection rc) Adds a collection of filesystem resources to copy.
| |
| addFileset | back to summary |
|---|---|
| public void addFileset(FileSet set) Adds a set of files to copy.
| |
| addPreserveInTarget | back to summary |
|---|---|
| public void addPreserveInTarget(Sync. A container for patterns and selectors that can be used to specify files that should be kept in the target even if they are not present in any source directory. You must not invoke this method more than once.
| |
| assertTrue | back to summary |
|---|---|
| private static void assertTrue(String message, boolean condition) Pseudo-assert method. | |
| configureTask | back to summary |
|---|---|
| private void configureTask(Task helper) | |
| execute | back to summary |
|---|---|
| public void execute() throws BuildException Overrides org. Execute the sync task.
| |
| getExplicitPreserveEmptyDirs | back to summary |
|---|---|
| private Boolean getExplicitPreserveEmptyDirs() The value of preserveTarget's preserveEmptyDirs attribute if specified and preserveTarget has been used in the first place.
| |
| init | back to summary |
|---|---|
| public void init() throws BuildException Overrides org. Initialize the sync task.
| |
| logRemovedCount | back to summary |
|---|---|
| private void logRemovedCount(int count, String prefix, String singularSuffix, String pluralSuffix) | |
| removeEmptyDirectories | back to summary |
|---|---|
| private int removeEmptyDirectories(File dir, boolean removeIfEmpty, Set<File> preservedEmptyDirectories) Removes all empty directories from a directory. Note that a directory that contains only empty directories, directly or not, will be removed! Recurses depth-first to find the leaf directories which are empty and removes them, then unwinds the recursion stack, removing directories which have become empty themselves, etc... | |
| removeEmptyDirectories | back to summary |
|---|---|
| private int removeEmptyDirectories(Set<File> preservedEmptyDirectories) Removes all empty directories preserved by preserveInTarget in the preserveEmptyDirs == FALSE case. Relies on the set to be ordered in reversed lexicographic order so that directories will be removed depth-first. | |
| removeOrphanFiles | back to summary |
|---|---|
| private int[] removeOrphanFiles(Set<String> nonOrphans, File toDir, Set<File> preservedDirectories) Removes all files and folders not found as keys of a table (used as a set!). If the provided file is a directory, it is recursively scanned for orphaned files which will be removed as well. If the directory is an orphan, it will also be removed.
| |
| setFailOnError | back to summary |
|---|---|
| public void setFailOnError(boolean failonerror) If false, note errors to the output but keep going.
| |
| setGranularity | back to summary |
|---|---|
| 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.
| |
| setIncludeEmptyDirs | back to summary |
|---|---|
| public void setIncludeEmptyDirs(boolean includeEmpty) Used to copy empty directories.
| |
| setOverwrite | back to summary |
|---|---|
| public void setOverwrite(boolean overwrite) Overwrite any existing destination file(s).
| |
| setTodir | back to summary |
|---|---|
| public void setTodir(File destDir) Sets the destination directory.
| |
| setVerbose | back to summary |
|---|---|
| public void setVerbose(boolean verbose) Used to force listing of all names of copied files.
| |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if emptyDirs are to be includedGet the includeEmptyDirs attribute. |
| public File | |
| protected void | |
| protected Map | scan(Resource[]
The source resources. resources, File The destination directory. toDir)Overrides org. |
| protected boolean | Returns: true always.Overrides org. |
| nonOrphans | back to summary |
|---|---|
| private Set<String> nonOrphans | |
| MyCopy | back to summary |
|---|---|
| public MyCopy() | |
| getIncludeEmptyDirs | back to summary |
|---|---|
| public boolean getIncludeEmptyDirs() Get the includeEmptyDirs attribute.
| |
| getToDir | back to summary |
|---|---|
| public File getToDir() Get the destination directory.
| |
| scan | back to summary |
|---|---|
| protected void scan(File fromDir, File toDir, String[] files, String[] dirs) Overrides org. Doc from org. Compares source files to destination files to see if they should be copied. | |
| scan | back to summary |
|---|---|
| protected Map Overrides org. Doc from org. Compares source resources to destination files to see if they should be copied. | |
| supportsNonFileResources | back to summary |
|---|---|
| protected boolean supportsNonFileResources() Overrides org. Yes, we can.
| |
| Modifier and Type | Field and Description |
|---|---|
| private Boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Boolean | Returns: BooleanWhether empty directories matched by this fileset should be preserved. |
| public void | setDir(File
ignored dir)Overrides org. |
| public void | setPreserveEmptyDirs(boolean
boolean b)Whether empty directories matched by this fileset should be preserved. |
| private FileSet |
| preserveEmptyDirs | back to summary |
|---|---|
| private Boolean preserveEmptyDirs | |
| SyncTarget | back to summary |
|---|---|
| public SyncTarget() Constructor for SyncTarget. This just changes the default value of "defaultexcludes" from true to false. | |
| getPreserveEmptyDirs | back to summary |
|---|---|
| public Boolean getPreserveEmptyDirs() Whether empty directories matched by this fileset should be preserved.
| |
| setDir | back to summary |
|---|---|
| public void setDir(File dir) throws BuildException Overrides org. Override AbstractFileSet#setDir(File) to disallow setting the directory.
| |
| setPreserveEmptyDirs | back to summary |
|---|---|
| public void setPreserveEmptyDirs(boolean b) Whether empty directories matched by this fileset should be preserved.
| |
| toFileSet | back to summary |
|---|---|
| private FileSet toFileSet(boolean withPatterns) | |