Green Apple
Green Apple

Reputation:

How can I process only files that have changed?

At the moment I'm doing this:

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

and repeating the same thing for other files - but it takes a long time.

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

How can I do that?

Upvotes: 3

Views: 4231

Answers (2)

Douglas Borg
Douglas Borg

Reputation: 61

Look into the sync task.

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

<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>

Upvotes: 6

Ry4an Brase
Ry4an Brase

Reputation: 78330

You need to use a selector on a FileSet. Something like this:

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

That compares your working dir to a clean checkout you have elsewhere, and returns the files whose last modified times have changed. You can use the fileset as the argument for a <delete> or a <copy>.

Upvotes: 4

Related Questions