Kees van Dieren wrote:
Hi all,
We use Filesets and regex mappers to select files for copying. How does Ant
decide, which file to take in case of duplicates? I hoped that this was on
modification date, however, this seems to be not always true, in most cases
it does but in some, it does not (unpredicable in which).
There is no definition, and deliberately so. It depends too much on what
is going on with the local file system (the order it returns things) and
the underlying JVM.
Example of what we do (very much simplified)
<fileset dir="../" id="module-fileset" >
<include name="module1/war/file1.html**"/>
<include name="module1/war/file2.html**"/>
<include name="module2/war/file1.html**"/>
<include name="module2/war/file3.html**"/>
</fileset>
This fileset is generated, dependant of module existance for this project.
Regular expression mapper:
<mapper id="module-war-mapper" type="regexp" from="^[a-z|\-]+/war/(.*)"
to="\1" />
We copy the files the folowing way:
<copy todir="${build.war.dir}">
<fileset refid="module-fileset" />
<mapper refid="module-war-mapper" />
</copy>
The result of this copy action, is that in ${build.war.dir}, three files
exists:
file1.html
file2.html
file3.html
What we need to reach, is that if module2 is not in the fileset, file1 from
module1 is taken; however, when module2 exists, file1.html from module2 must
be taken.
The file1.html in module 1 is never modified (it's just a dummy file), so
file1.html in module2 is always newer (last modified timestamp is later).
How can we make sure that, if module2 exists, it picks up the file1.html
from module2?
Multiple copies? copy module 1 first and only do the module 1 copy
after, using whatever attribute on copy says "preserve timestamps". By
preserving timestamps ant will see that module1/file1.html is older,
even after the copy, so overwrite it. Better yet, exclude file1.html
from module1.
steve
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]