Of course it can be done using the exec task
, but my question is:
Is it possible to do it using the tar task?
I don't think there is a way to retain existing permissions, per this note from the copy task:
Unix Note: File permissions are not retained when files are copied; they end up with the default UMASK permissions instead. This is caused by the lack of any means to query or set file permissions in the current Java runtimes. If you need a permission-preserving copy function, use
<exec executable="cp" ... >
instead.
However the tar task can take one or more tarfileset
elements. The tarfileset
can be defined with a filemode
and/or dirmode
attribute to specify the unix permissions. If you specify multiple includes matching only those files to get each set of required permissions, the files in that set will be included with those permissions.