ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject Multiple fileset and filelist comparisons
Date Tue, 26 Apr 2016 09:25:58 GMT
Hi all,

How would you  do to implement this with ANT ?

1- In a project A, there are 2 file trees with same directories and files but not at same
-----file1 (version 1.2)
-----file2 (version 2.3)
-----file3 (version 3.0)

-----file1 (version 1.2)
-----file2 (version 2.1)
-----file3 (version 3.0)

I need to compare those 2 file trees to get desynchronized files from 'DirRemote' (in order
to synchronize them with the latest revision further).
I can do this easily with 'different' selector on 'targetdir' DirRemote :
<fileset dir="${DirLocal}" includes="**/*.xml" id="desynchronizedMetadata">
    <different targetdir="${DirRemote}" ignoreFileTimes="true"/>

But this list of desynchronised files will be used by another project B, that's why I convert
the fileset 'desynchronizedMetadata into a fileList using a pathconvert and echo file :
<pathconvert pathsep="${line.separator}" property="desynch.files" refid="desynchronizedMetadata">
    <regexpmapper from="^${DirLocal}/(.*)$" to="&lt;file name=&quot;\1&quot;/>"
 <echo file="desynchronizedMetadata.xml">&lt;project name=&quot;DesynchronizedMetadata&quot;>${line.separator}&lt;filelist
id=&quot;desynch.files&quot; dir=&quot;${DirLocal}&quot;>

2- In the project B, I import this fileList and I need to clean it against another files tree
DirMostUpToDate (same directories and files), but in another way.
If a file is present both in fileList and in the file tree then this file will be removed
from the fileList. Here the test to know if the file is present on the 2 sides is based on
the relative path, not on the content (relative path : subdir1/file1)
To do this comparison (without success) I tried to:
- option 1: compare 2 resources : one from the fileList and the other from the fileset 'DirMostUpToDate'
and then to use 'intersect' :

<import file="${projectA}/desynchronizedMetadata.xml" optional="true"/>
<resources id="A" >
    <filelist refid="desynch.files"/>
<fileset dir="${DirMostUpToDate }" includes="**/*xml" id="metadata">
<resources id="B">
    <fileset refid="metadata"/>
<intersect id="intersect"><resources refid="A"/><resources refid="B"/></intersect>
But actually it doesn't work, it returns nothing (if I do the same with using 'difference',
it returns list of all files like 'union')

- option 2: then I tried to convert the fileList into a fileset to be able to use the fileset
comparison like in project A but it looks like very crappy ! I converted the fileList into
a comma delimited list of files property and then create a fileset using this property in
'includes' attribute but this list could be quiet huge so I'm not sure this is the efficient
way to do this.

- option 3: I could loop on the fileList and check the availability of the current file in
dir DirMostUpToDate but again it seems to be inefficient in case of huge fileList

All suggestions are welcome !
Many thanks
P.S : one thing could not be debated: the 2 projects A et B are completely separated. Project
B cannot compare DirLocal and DirRemote and must use a fileList (or something else ?) present
in the file system.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message