16

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?

zombat
  • 92,731
  • 24
  • 156
  • 164
Wernight
  • 36,122
  • 25
  • 118
  • 131

3 Answers3

22

The following does work:

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

Credits shared with the OP.

See also

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
4

To chmod one can use exec:

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

Credits

Community
  • 1
  • 1
DmitrySandalov
  • 3,879
  • 3
  • 23
  • 17
2

Here's the gradle version :

task fixPermissions << {
    ant.chmod(dir:"$rootDir/foo", perm:"g+w", includes:"**/*")
}
ohad serfaty
  • 644
  • 6
  • 11