For anyone else who accesses this and needs code, here is the task of synchronizing one location with another based on the content, not the timestamp, it uses the changed selector and not the other in another answer to give more control over the difference of the files:
<project name="Demo" default="newSync"> <description> Sync from ${foo} to ${bar} </description> <macrodef name="syncContents"> <attribute name="from"/> <attribute name="to"/> <sequential> <fileset id="selectCopyFiles" dir="@{from}"> <modified algorithm="hashvalue"/> </fileset> <fileset id="selectDeleteFiles" dir="@{to}"> <not> <present targetdir="@{from}"/> </not> </fileset> <copy overwrite="true" todir="@{to}"> <fileset refid="selectCopyFiles"/> </copy> <delete includeEmptyDirs="true"> <fileset refid="selectDeleteFiles"/> </delete> </sequential> </macrodef> <target name="newSync"> <syncContents from="${foo}" to="${bar}"/> </target> </project>
Note that the foo bar-mirror does this (synchronization A-> B), if you want bi-directional synchronization, you can replace the deletion with a copy from B-> A and provide a concatenated task to handle changes to the same file in both places.
Mileshampson
source share