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

2019-04-19 02:43发布

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?

3条回答
【Aperson】
2楼-- · 2019-04-19 03:06

The following does work:

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

Credits shared with the OP.

See also

查看更多
Rolldiameter
3楼-- · 2019-04-19 03:11

To chmod one can use exec:

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

Credits

查看更多
做个烂人
4楼-- · 2019-04-19 03:20

Here's the gradle version :

task fixPermissions << {
    ant.chmod(dir:"$rootDir/foo", perm:"g+w", includes:"**/*")
}
查看更多
登录 后发表回答