You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

setpermissions.html 4.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <meta http-equiv="Content-Language" content="en-us">
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>SetPermissions Task</title>
  20. </head>
  21. <body>
  22. <h2 id="setpermissions">SetPermissions</h2>
  23. <p><em>Since Ant 1.10.0</em>.</p>
  24. <h3>Description</h3>
  25. <p>Changes the file permissions using Java's NIO support for
  26. permissions.</p>
  27. <p>This task provides a subset of the platform specific abilities of
  28. <a href="chmod.html">chmod</a> and <a href="attrib.html">attrib</a>
  29. in a platform independent way.</p>
  30. <p>If no permissions are specified either via the mode or the
  31. permissions attribute, then all permissions will be removed from the
  32. nested resources.</p>
  33. <p>The task accepts arbitrary resources as part of the nested
  34. resource collections, but not all resources support setting
  35. permissions. This task won't do anything for resources that don't
  36. support setting permissions - for example URLs.</p>
  37. <p>The permissions are applied to all resources contained within the
  38. nested resources collections. You may want to ensure the collection
  39. only returns files or directories if you want different sets of
  40. permissions to apply to either type of resource.</p>
  41. <h3>Parameters</h3>
  42. <table>
  43. <tr>
  44. <td valign="top"><b>Attribute</b></td>
  45. <td valign="top"><b>Description</b></td>
  46. <td align="center" valign="top"><b>Required</b></td>
  47. </tr>
  48. <tr>
  49. <td valign="top">permissions</td>
  50. <td valign="top">The permissions to set as comma separated list of
  51. names
  52. of <a href="http://docs.oracle.com/javase/8/docs/api/java/nio/file/attribute/PosixFilePermission.html">PosixFilePermission</a>
  53. values.</td>
  54. <td valign="top" align="center">No</td>
  55. </tr>
  56. <tr>
  57. <td valign="top">mode</td>
  58. <td valign="top">The permissions to set as traditional Unix
  59. three-digit octal number.</td>
  60. <td valign="top" align="center">No</td>
  61. </tr>
  62. <tr>
  63. <td valign="top">nonPosixMode</td>
  64. <td valign="top">What to do if changing the permissions of a file
  65. is not possible because the file-system doesn't support POSIX
  66. file permissions. Possible options are <code>fail</code> (fail
  67. the build), <code>pass</code> (just log an
  68. error), <code>tryDosOrFail</code> (at least try to set the
  69. read-only flag on DOS file systems, fail if that isn't possible
  70. either) and <code>tryDosOrPass</code> (at least try to set the
  71. read-only flag on DOS file systems, just log an error if that
  72. isn't possible either).</td>
  73. <td valign="top" align="center">No, defaults to <code>fail</code></td>
  74. </tr>
  75. <tr>
  76. <td valign="top">failonerror</td>
  77. <td valign="top">Whether to stop the build if setting permissions
  78. fails.</td>
  79. <td valign="top" align="center">No, defaults to true</td>
  80. </tr>
  81. </table>
  82. <h3>Parameters specified as nested elements</h3>
  83. <h4>any resource collection</h4>
  84. <p><a href="../Types/resources.html#collection">Resource
  85. Collection</a>s are used to select groups of resources.</p>
  86. <h3>Examples</h3>
  87. <blockquote><pre>
  88. &lt;setpermissions mode=&quot;755&quot;&gt;
  89. &lt;file file=&quot;${dist}/start.sh&quot;/&gt;
  90. &lt;/setpermissions&gt;
  91. </pre></blockquote>
  92. <p>makes the &quot;start.sh&quot; file readable and executable for
  93. anyone and in addition writable by the owner.</p>
  94. <blockquote><pre>
  95. &lt;setpermissions permissions=&quot;OWNER_READ,OWNER_WRITE,OWNER_EXECUTE,OTHERS_READ,OTHERS_EXECUTE,GROUP_READ,GROUP_EXECUTE&quot;&gt;
  96. &lt;file file=&quot;${dist}/start.sh&quot;/&gt;
  97. &lt;/setpermissions&gt;
  98. </pre></blockquote>
  99. <p>makes the &quot;start.sh&quot; file readable and executable for
  100. anyone and in addition writable by the owner.</p>
  101. </body>
  102. </html>