问题描述
ant中是否有任何命令可以将文件从一个文件夹结构复制到另一文件夹结构,而无需是否覆盖文件.基本上,我希望从文件夹A到文件夹B的所有多余文件.也就是说: overwriting files. Basically I want all extra files from folder A to folder B. That is: no files of folder B are replaced but extra files of folder A comes to folder B.
我看到了蚂蚁复制"和蚂蚁移动"命令,但没有帮助.有任何建议.
I saw "ant copy" and "ant move" commands, but didn't help. Any suggestions.
推荐答案
Ant的复制任务的overwrite属性状态为:即使目标文件是较新的,也要覆盖现有文件."
Ant's copy task's overwrite attribute states:"Overwrite existing files even if the destination files are newer."
因此,将其设置为false只会阻止它们在较新的情况下被覆盖,但是在原始文件较新的情况下,无论如何它们都将被覆盖.
So setting it to false only prevents them from being overwritten if they are newer, but if the original files are newer, they overwrite no matter what.
我发现解决此问题的唯一方法是在复制之前触摸目标文件,即:
The only way i've found to get around this is to touch the destination files before copying, i.e:
<touch>
<fileset dir="${dest.dir}"/>
</touch>
<copy todir="${dest.dir}" overwrite="false">
<fileset dir="${src.dir}"/>
</copy>
这篇关于Ant复制文件而不会覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!