ASF Bugzilla – Full Text Bug Listing
|Summary:||sync does not work with zipfileset|
|Component:||Core tasks||Assignee:||Ant Notifications List <notifications>|
Description kai 2011-07-01 12:37:19 UTC
I was happy to see that "sync" supports the "zipfileset" because I need to sync a destination folder with the contents of a source .jar/.zip file. I cannot just unzip the contents of the .jar/.zip file because dangling files that were removed in the .zip file would still be present in the target directory. So, I really need a sync here. Now, I have the following simple target: <target name="test"> <sync todir="dir"> <zipfileset src="test.zip" /> </sync> </target> The "test.zip" is a simple zip file which has one entry. The directory "dir" is initially empty. Executing this target results in the entry of the zip file being copied into "dir". BUT: Executing the target a second time results in the copied file being removed from "dir" and "dir" is afterwards empty! It seems that files that exist both in the target folder and the source file are removed from the target folder and files that only exist in the source file are copied into the target folder...
Comment 1 ahagerup 2011-07-26 20:01:32 UTC
This seems to be a general problem with <sync> support for resource collections. The following exhibits the same behavior: <target name="test"> <sync todir="tgt"> <mappedresources> <fileset dir="src"/> <globmapper from="*" to="test/*"/> </mappedresources> </sync> </target> Also, according to the documentation, the <sync> task "Synchronize a target directory from the files defined in one or more Resource Collections", however only one resource collection is allowed (multiple <fileset>'s work). The following fails with "Restrict$1 expects exactly one nested resource collection": <target name="test"> <sync todir="tgt"> <mappedresources> <fileset dir="src1"/> <globmapper from="*" to="test1/*"/> </mappedresources> <mappedresources> <fileset dir="src2"/> <globmapper from="*" to="test2/*"/> </mappedresources> </sync> </target> On a final documentation note, it says that "To use a resource collection, the todir attribute must be set", which is very redundant since the todir attribute is required for the <sync> task. Probably a copy/paste from the <copy> task.
Comment 2 Stefan Bodewig 2011-07-27 07:38:42 UTC
with svn revision 1151369 sync really supports multiple resource collections (and the todir reference has been removed from the manual). I have a failing AntUnit test based on mappedResources that reproduces the bug, will look into it.