How to process only files that have been changed?

I am currently doing this:

<delete dir="${RSA.dir}/file1" />
<copy todir="${RSA.dir}/file1" >
    <fileset dir="${CLEARCASE.dir}/file1" />            
</copy>

and repeat the same thing for other files, but it takes a lot of time.

I only want to delete and copy files that have been updated, with their modified date in the box later than in RSA.

How can i do this?

+3
source share
2 answers

Look at the sync task .

If you want to do this based on the contents of the file and ignore the timestamp, I think this macro will do this:

<macrodef name="mirror" description="Copy files only if different; remove files that do not exist in dir. This works similiar to robocopy /MIR." >
    <attribute name="dir"/>
    <attribute name="todir"/>
    <sequential>
        <copy overwrite="true" todir="@{todir}">
            <fileset dir="@{dir}">
                <different targetdir="${todir}"/>
            </fileset>
        </copy>
        <delete includeemptydirs="true">
            <fileset dir="@todir}">
                <present targetdir="${dir}" present="srconly"/>
            </fileset>                
        </delete>
    </sequential>
</macrodef>
+5
source

You need to use selector in FileSet. Something like that:

<fileset dir="${your.working.dir}/src/main" includes="**/*.java">
    <different targetdir="${clean.clearcase.checkout}/src/main"
        ignoreFileTimes="false"
        ignoreContents="true" />
</fileset>

, , , . <delete> <copy>.

+4

Source: https://habr.com/ru/post/1712524/


All Articles