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.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 permissions.</p>
  26. <p>This task provides a subset of the platform specific abilities of <a href="chmod.html">chmod</a>
  27. and <a href="attrib.html">attrib</a> in a platform independent way.</p>
  28. <p>If no permissions are specified either via the mode or the permissions attribute, then all
  29. permissions will be removed from the nested resources.</p>
  30. <p>The task accepts arbitrary resources as part of the nested resource collections, but not all
  31. resources support setting permissions. This task won't do anything for resources that don't support
  32. setting permissions&mdash;for example URLs.</p>
  33. <p>The permissions are applied to all resources contained within the nested resources
  34. collections. You may want to ensure the collection only returns files or directories if you want
  35. different sets of permissions to apply to either type of resource.</p>
  36. <h3>Parameters</h3>
  37. <table class="attr">
  38. <tr>
  39. <th>Attribute</th>
  40. <th>Description</th>
  41. <th>Required</th>
  42. </tr>
  43. <tr>
  44. <td>permissions</td>
  45. <td>The permissions to set as comma separated list of names
  46. of <a href="https://docs.oracle.com/javase/8/docs/api/java/nio/file/attribute/PosixFilePermission.html"
  47. target="_top">PosixFilePermission</a> values.</td>
  48. <td>No</td>
  49. </tr>
  50. <tr>
  51. <td>mode</td>
  52. <td>The permissions to set as traditional Unix three-digit octal number.</td>
  53. <td>No</td>
  54. </tr>
  55. <tr>
  56. <td>nonPosixMode</td>
  57. <td>What to do if changing the permissions of a file is not possible because the file-system
  58. doesn't support POSIX file permissions. Possible options are <q>fail</q> (fail the
  59. build), <q>pass</q> (just log an error), <q>tryDosOrFail</q> (at least try to set the
  60. read-only flag on DOS file systems, fail if that isn't possible either)
  61. and <q>tryDosOrPass</q> (at least try to set the read-only flag on DOS file systems, just log
  62. an error if that isn't possible either).</td>
  63. <td>No; defaults to <q>fail</q></td>
  64. </tr>
  65. <tr>
  66. <td>failonerror</td>
  67. <td>Whether to stop the build if setting permissions fails.</td>
  68. <td>No; defaults to <q>true</q></td>
  69. </tr>
  70. </table>
  71. <h3>Parameters specified as nested elements</h3>
  72. <h4>any resource collection</h4>
  73. <p><a href="../Types/resources.html#collection">resource collections</a> are used to select groups
  74. of resources.</p>
  75. <h3>Examples</h3>
  76. <pre>
  77. &lt;setpermissions mode=&quot;755&quot;&gt;
  78. &lt;file file=&quot;${dist}/start.sh&quot;/&gt;
  79. &lt;/setpermissions&gt;</pre>
  80. <p>makes the <samp>start.sh</samp> file readable and executable for anyone and in addition writable
  81. by the owner.</p>
  82. <pre>
  83. &lt;setpermissions permissions=&quot;OWNER_READ,OWNER_WRITE,OWNER_EXECUTE,OTHERS_READ,OTHERS_EXECUTE,GROUP_READ,GROUP_EXECUTE&quot;&gt;
  84. &lt;file file=&quot;${dist}/start.sh&quot;/&gt;
  85. &lt;/setpermissions&gt;</pre>
  86. <p>makes the <samp>start.sh</samp> file readable and executable for anyone and in addition writable
  87. by the owner.</p>
  88. </body>
  89. </html>