I need to copy a group of files with ant. Unfortunately I can't use the target "copy" because it loses the Linux file permissions. So must use the target "execute" "cp" . How can I pass a group of file to the execute cp target? I know that I have to use a fileset but in which manner I can pass a fileset as argument of the execute cp target?
Asked
Active
Viewed 1,564 times
1 Answers
2
You can't pass filesets to operating system commands. The best you can do is use the apply task to invoke the "cp" command on each file as follows:
<apply executable="cp">
<srcfile/>
<targetfile/>
<fileset dir="src" includes="*.txt"/>
<globmapper from="*.txt" to="output/*.txt"/>
</apply>
But, I don't really understand why you couldn't combine the copy task with chmod, it would be most efficient:
<copy todir="output">
<fileset dir="src" includes="*.txt"/>
</copy>
<chmod perm="700">
<fileset dir="output" includes="*.txt"/>
</chmod>

Mark O'Connor
- 76,015
- 10
- 139
- 185
-
1I can't use the second target (the one with chmod perm="700") because not all the file that I want to copy have the same permissions and I would like to preserve the original pattern of each one. In any case the first target that you posted works perfectly. Thanks very very much it's a lot of time that I search for a solution to this problem. :) – user2572526 Oct 28 '13 at 09:03