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

牧云@^-^@ 提交于 2020-01-02 00:38:08

问题


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?


回答1:


The following does work:

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

Credits shared with the OP.

See also

  • Chmod Task



回答2:


To chmod one can use exec:

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

Credits




回答3:


Here's the gradle version :

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


来源:https://stackoverflow.com/questions/3241867/how-to-chmod-r-w-with-ant-files-and-folders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!