Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to `chmod -R +w` with Ant, files and folders?

I'd like to do the equivalent of a chmod -R +w foo/ in an Ant build script.

So far I'm using this:

<chmod perm="g+w">
   <dirset dir="${basedir}/foo">
   </dirset>
   <fileset dir="${basedir}/foo">
   </fileset>
</chmod>

Is there a neater way to write that to include files and folders recursively?

like image 905
Wernight Avatar asked Jul 13 '10 21:07

Wernight


People also ask

How do I chmod all files in a directory?

Changing permissions with chmod To modify the permission flags on existing files and directories, use the chmod command ("change mode"). It can be used for individual files or it can be run recursively with the -R option to change permissions for all of the subdirectories and files within a directory.

What is 775 chmod?

The chmod 775 is an essential command that assigns read, write, and execute permission to a specific user, group, or others.


3 Answers

To chmod one can use exec:

<exec executable="chmod" dir="${basedir}/foo" failonerror="true">
    <arg line="-R 0755 ." />
</exec>

Credits

like image 25
DmitrySandalov Avatar answered Oct 14 '22 12:10

DmitrySandalov


The following does work:

<chmod file="${basedir}/foo/**" perm="g+w" type="both"/>

Credits shared with the OP.

See also

  • Chmod Task
like image 130
Pascal Thivent Avatar answered Oct 14 '22 11:10

Pascal Thivent


Here's the gradle version :

task fixPermissions << {
    ant.chmod(dir:"$rootDir/foo", perm:"g+w", includes:"**/*")
}
like image 2
ohad serfaty Avatar answered Oct 14 '22 11:10

ohad serfaty