Let’s say I copy some files with ant, from a network drive:
<copy todir="." verbose="true">
<fileset dir="some_directory" includes="**/*"/>
</copy>
Let’s say I test if the folder exists first.
<available file="${dir.local}" property="dir.exists"/>
If I have the folder on my computer, I would like to only copy the files that are modified. Is there any way of keeping up2date with the version that exists on the server?
EDIT: I know about the sync task. The thing is, if my local files are modified, sync does not copy them. Is there any way to go around that behaviour, or is there another task which can do this?
EDIT2: here’s the code modified to according to Peter’s suggestions:
<target name="copy">
<echo>${dir.remote}</echo>
<copy todir="${dir.local}" verbose="true" overwrite="true"
preservelastmodified="true">
<fileset dir="${dir.remote}">
<include name="**/*"/>
</fileset>
</copy>
</target>
This however copies all the files. It’s not only replacing the modified ones.
Edit: I might be wrong, but I don’t think that such a task exists.
One way to do this would be to write your own Ant Task extending the
Copytask and overridingcopySingleFilewhich checks the timestamp:Ant
copydoes not overwrite existing files unless the source is newer:Use
preservelastmodifiedto make sure that timestamps match.