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.

chgrp.html 6.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <!DOCTYPE html>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. https://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <html lang="en">
  17. <head>
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>Chgrp Task</title>
  20. </head>
  21. <body>
  22. <h2 id="chgrp">Chgrp</h2>
  23. <p><em>Since Apache Ant 1.6</em>.</p>
  24. <h3>Description</h3>
  25. <p>Changes the group of a file or all files inside specified directories. Right now it has effect
  26. only under Unix. The group attribute is equivalent to the corresponding argument for
  27. the <kbd>chgrp</kbd> command.</p>
  28. <p><a href="../Types/fileset.html">FileSet</a>s, <a href="../Types/dirset.html">DirSet</a>s
  29. or <a href="../Types/filelist.html">FileList</a>s can be specified using
  30. nested <code>&lt;fileset&gt;</code>, <code>&lt;dirset&gt;</code> and <code>&lt;filelist&gt;</code>
  31. elements.</p>
  32. <p><em>Since Ant 1.7</em>, this task supports
  33. arbitrary <a href="../Types/resources.html#collection">resource collections</a> as nested
  34. elements.</p>
  35. <p>By default this task will use a single invocation of the underlying <kbd>chgrp</kbd> command.
  36. If you are working on a large number of files this may result in a command line that is too long for
  37. your operating system. If you encounter such problems, you should set the <var>maxparallel</var>
  38. attribute of this task to a non-zero value. The number to use highly depends on the length of your
  39. file names (the depth of your directory tree) and your operating system, so you'll have to
  40. experiment a little. POSIX recommends command line length limits of at least 4096 characters, this
  41. may give you an approximation for the number you could use as initial value for these
  42. experiments.</p>
  43. <p>By default this task won't do anything unless it detects it is running on a Unix system. If you
  44. know for sure that you have a <kbd>chgrp</kbd> executable on your <code>PATH</code> that is
  45. command line compatible with the Unix command, you can use the task's <var>os</var> attribute and
  46. set its value to your current OS.</p>
  47. <h3>Parameters</h3>
  48. <table class="attr">
  49. <tr>
  50. <th scope="col">Attribute</th>
  51. <th scope="col">Description</th>
  52. <th scope="col">Required</th>
  53. </tr>
  54. <tr>
  55. <td>file</td>
  56. <td>the file or directory of which the group must be changed.</td>
  57. <td>Yes, unless nested <code>&lt;fileset|filelist|dirset&gt;</code> elements are specified</td>
  58. </tr>
  59. <tr>
  60. <td>group</td>
  61. <td>the new group.</td>
  62. <td>Yes</td>
  63. </tr>
  64. <tr>
  65. <td>parallel</td>
  66. <td>process all specified files using a single <kbd>chgrp</kbd> command.</td>
  67. <td>No; defaults to <q>true</q></td>
  68. </tr>
  69. <tr>
  70. <td>type</td>
  71. <td>One of <q>file</q>, <q>dir</q> or <q>both</q>. If set to <q>file</q>, only the group of
  72. plain files are going to be changed. If set to <q>dir</q>, only the directories are
  73. considered.<br/><strong>Note</strong>: The type attribute does not apply to
  74. nested <code>dirset</code>s&mdash;<code>dirset</code>s always implicitly assume type to
  75. be <q>dir</q>.</td>
  76. <td>No; default is <q>file</q></td>
  77. </tr>
  78. <tr>
  79. <td>maxparallel</td>
  80. <td>Limit the amount of parallelism by passing at most this many sourcefiles at once. Set it to
  81. negative integer for unlimited.</td>
  82. <td>No; defaults to unlimited</td>
  83. </tr>
  84. <tr>
  85. <td>verbose</td>
  86. <td>Whether to print a summary after execution or not.</td>
  87. <td>No; defaults to <q>false</q></td>
  88. </tr>
  89. <tr>
  90. <td>os</td>
  91. <td>list of Operating Systems on which the command may be executed.</td>
  92. <td>No</td>
  93. </tr>
  94. <tr>
  95. <td>osfamily</td>
  96. <td>OS family as used in the <a href="../Tasks/conditions.html#os">&lt;os&gt;</a>
  97. condition.</td>
  98. <td>No; defaults to <q>unix</q></td>
  99. </tr>
  100. </table>
  101. <h3>Examples</h3>
  102. <p>Make the <samp>start.sh</samp> file belong to the <samp>coders</samp> group on a UNIX system.</p>
  103. <pre>&lt;chgrp file=&quot;${dist}/start.sh&quot; group=&quot;coders&quot;/&gt;</pre>
  104. <p>Make all <samp>.sh</samp> files below <samp>${dist}/bin</samp> belong to the <samp>coders</samp>
  105. group on a UNIX system.</p>
  106. <pre>
  107. &lt;chgrp group=&quot;coders&quot;&gt;
  108. &lt;fileset dir=&quot;${dist}/bin&quot; includes=&quot;**/*.sh&quot;/&gt;
  109. &lt;/chgrp&gt;</pre>
  110. <p>Make all files below <samp>shared/sources1</samp> (except those below any directory
  111. named <samp>trial</samp>) belong to the <samp>coders</samp> group on a UNIX system. In addition, all
  112. files belonging to a FileSet with <var>id</var>=<samp>other.shared.sources</samp> get the same
  113. group.</p>
  114. <pre>
  115. &lt;chgrp group=&quot;coders&quot;&gt;
  116. &lt;fileset dir=&quot;shared/sources1&quot;&gt;
  117. &lt;exclude name=&quot;**/trial/**&quot;/&gt;
  118. &lt;/fileset&gt;
  119. &lt;fileset refid=&quot;other.shared.sources&quot;/&gt;
  120. &lt;/chgrp&gt;
  121. </pre>
  122. <p>Make all <samp>.test.jsp</samp>, and <samp>.new</samp> files belong to
  123. group <samp>webdev</samp>. Directories with names beginning with <samp>test_</samp> also will belong
  124. to <samp>webdev</samp>, but if there is a directory name that ends in <samp>.new</samp> or a file
  125. name that begins with <samp>test_</samp> it will be unaffected.</p>
  126. <pre>
  127. &lt;chgrp group=&quot;webdev&quot; type=&quot;file&quot;&gt;
  128. &lt;fileset dir=&quot;/web&quot;&gt;
  129. &lt;include name=&quot;**/*.test.jsp&quot;/&gt;
  130. &lt;include name=&quot;**/*.new&quot;/&gt;
  131. &lt;/fileset&gt;
  132. &lt;dirset dir=&quot;/web&quot;&gt;
  133. &lt;include name=&quot;**/test_*&quot;/&gt;
  134. &lt;/dirset&gt;
  135. &lt;/chmod&gt;</pre>
  136. </body>
  137. </html>