ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Lancelot.MEURIL...@oecd.org>
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
revision
DirLocal
--subdir1
-----file1 (version 1.2)
-----file2 (version 2.3)
--subdir2
-----file3 (version 3.0)

DirRemote
--subdir1
-----file1 (version 1.2)
-----file2 (version 2.1)
--subdir2
-----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"/>
</fileset>

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;/>"
handledirsep="true"/>
</pathconvert>
 <echo file="desynchronizedMetadata.xml">&lt;project name=&quot;DesynchronizedMetadata&quot;>${line.separator}&lt;filelist
id=&quot;desynch.files&quot; dir=&quot;${DirLocal}&quot;>
 ${desynch.files}
 &lt;/filelist>${line.separator}&lt;/project></echo>


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"/>
</resources>
  
<fileset dir="${DirMostUpToDate }" includes="**/*xml" id="metadata">
<resources id="B">
    <fileset refid="metadata"/>
</resources>
<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
Lancelot
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: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message