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.

move.html 7.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  5. <title>Move Task</title>
  6. </head>
  7. <body>
  8. <h2><a name="move">Move</a></h2>
  9. <h3>Description</h3>
  10. <p>Moves a file to a new file or directory, or sets of files to
  11. a new directory. By default, the
  12. destination file is overwritten if it already exists. When <var>overwrite</var> is
  13. turned off, then files are only moved if the source file is newer than
  14. the destination file, or when the destination file does not exist.</p>
  15. <p><a href="../CoreTypes/fileset.html">FileSet</a>s are used to select sets of files
  16. to move to the <var>todir</var> directory.</p>
  17. <p><b>Since Ant 1.6.3</b>, the <i>file</i> attribute may be used to move
  18. (rename) an entire directory. If <i>tofile</i> denotes an existing file, or
  19. there is a directory by the same name in <i>todir</i>, the action will fail.
  20. </p>
  21. <h3>Parameters</h3>
  22. <table border="1" cellpadding="2" cellspacing="0">
  23. <tr>
  24. <td valign="top"><b>Attribute</b></td>
  25. <td valign="top"><b>Description</b></td>
  26. <td align="center" valign="top"><b>Required</b></td>
  27. </tr>
  28. <tr>
  29. <td valign="top">file</td>
  30. <td valign="top">the file or directory to move</td>
  31. <td valign="top" align="center">One of <var>file</var> or
  32. at least one nested fileset element</td>
  33. </tr>
  34. <tr>
  35. <td valign="top">preservelastmodified</td>
  36. <td valign="top">Give the moved files the same last modified
  37. time as the original source files.
  38. (<em>Note</em>: Ignored on Java 1.1)</td>
  39. <td valign="top" align="center">No; defaults to false.</td>
  40. </tr>
  41. <tr>
  42. <td valign="top">tofile</td>
  43. <td valign="top">the file to move to</td>
  44. <td valign="top" align="center" rowspan="2">With the <var>file</var> attribute,
  45. either <var>tofile</var> or <var>todir</var> can be used. With nested filesets,
  46. if the fileset size is greater than 1 or if the only entry in the fileset is a
  47. directory or if the <var>file</var> attribute is already specified, only
  48. <var>todir</var> is allowed</td>
  49. </tr>
  50. <tr>
  51. <td valign="top">todir</td>
  52. <td valign="top">the directory to move to</td>
  53. </tr>
  54. <tr>
  55. <td valign="top">overwrite</td>
  56. <td valign="top">overwrite existing files even if the destination
  57. files are newer (default is &quot;true&quot;)</td>
  58. <td valign="top" align="center">No</td>
  59. </tr>
  60. <tr>
  61. <td valign="top">filtering</td>
  62. <td valign="top">indicates whether token filtering should take place during
  63. the move. See the <a href="filter.html">filter</a> task for a description of
  64. how filters work.</td>
  65. <td valign="top" align="center">No</td>
  66. </tr>
  67. <tr>
  68. <td valign="top">flatten</td>
  69. <td valign="top">ignore directory structure of source directory,
  70. copy all files into a single directory, specified by the <var>todir</var>
  71. attribute (default is &quot;false&quot;).Note that you can achieve the
  72. same effect by using a <a href="../CoreTypes/mapper.html#flatten-mapper">flatten mapper</a></td>
  73. <td valign="top" align="center">No</td>
  74. </tr>
  75. <tr>
  76. <td valign="top">includeEmptyDirs</td>
  77. <td valign="top">Copy empty directories included with the nested FileSet(s).
  78. Defaults to &quot;yes&quot;.</td>
  79. <td valign="top" align="center">No</td>
  80. </tr>
  81. <tr>
  82. <td valign="top">failonerror</td>
  83. <td valign="top">If false, log a warning message, but do not stop the
  84. build, when the file to copy does not exist or one of the nested
  85. filesets points to a directory that doesn't exist or an error occurs
  86. while moving.
  87. </td>
  88. <td valign="top" align="center">No; defaults to true.</td>
  89. </tr>
  90. <tr>
  91. <td valign="top">verbose</td>
  92. <td valign="top">Log the files that are being moved.</td>
  93. <td valign="top" align="center">No; defaults to false.</td>
  94. </tr>
  95. <tr>
  96. <td valign="top">encoding</td>
  97. <td valign="top">The encoding to assume when filter-copying the
  98. files. <em>since Ant 1.5</em>.</td>
  99. <td align="center">No - defaults to default JVM encoding</td>
  100. </tr>
  101. <tr>
  102. <td valign="top">outputencoding</td>
  103. <td valign="top">The encoding to use when writing the files.
  104. <em>since Ant 1.6</em>.</td>
  105. <td align="center">No - defaults to the value of the encoding
  106. attribute if given or the default JVM encoding otherwise.</td>
  107. </tr>
  108. <tr>
  109. <td valign="top">enablemultiplemapping</td>
  110. <td valign="top">
  111. If true the task will process to all the mappings for a
  112. given source path. If false the task will only process
  113. the first file or directory. This attribute is only relevant
  114. if there is a mapper subelement.
  115. <em>since Ant 1.6</em>.</td>
  116. <td align="center">No - defaults to false.</td>
  117. </tr>
  118. <tr>
  119. <td valign="top">granularity</td>
  120. <td valign="top">The number of milliseconds leeway to give before
  121. deciding a file is out of date. This is needed because not every
  122. file system supports tracking the last modified time to the
  123. millisecond level. Default is 0 milliseconds, or 2 seconds on DOS
  124. systems. This can also be useful if source and target files live
  125. on separate machines with clocks being out of sync. <em>since Ant
  126. 1.6</em>.</td>
  127. </tr>
  128. </table>
  129. <h3>Parameters specified as nested elements</h3>
  130. <h4>mapper</h4>
  131. <p>You can define file name transformations by using a nested <a
  132. href="../CoreTypes/mapper.html">mapper</a> element. The default mapper used by
  133. <code>&lt;copy&gt;</code> is the <a
  134. href="../CoreTypes/mapper.html#identity-mapper">identity</a>.</p>
  135. <h4>filterchain</h4>
  136. <p>The Move task supports nested <a href="../CoreTypes/filterchain.html">
  137. FilterChain</a>s.</p>
  138. <p>
  139. If <code>&lt;filterset&gt;</code> and <code>&lt;filterchain&gt;</code> elements are used inside the
  140. same <code>&lt;move&gt;</code> task, all <code>&lt;filterchain&gt;</code> elements are processed first
  141. followed by <code>&lt;filterset&gt;</code> elements.
  142. </p>
  143. <h3>Examples</h3>
  144. <p><b>Move a single file (rename a file)</b></p>
  145. <pre>
  146. &lt;move file=&quot;file.orig&quot; tofile=&quot;file.moved&quot;/&gt;
  147. </pre>
  148. <p><b>Move a single file to a directory</b></p>
  149. <pre>
  150. &lt;move file=&quot;file.orig&quot; todir=&quot;dir/to/move/to&quot;/&gt;
  151. </pre>
  152. <p><b>Move a directory to a new directory</b></p>
  153. <pre>
  154. &lt;move todir=&quot;new/dir/to/move/to&quot;&gt;
  155. &lt;fileset dir=&quot;src/dir&quot;/&gt;
  156. &lt;/move&gt;
  157. </pre>
  158. <i>or, since Ant 1.6.3:</i>
  159. <pre>
  160. &lt;move file=&quot;src/dir&quot; tofile=&quot;new/dir/to/move/to&quot;/&gt;
  161. </pre>
  162. <p><b>Move a set of files to a new directory</b></p>
  163. <pre>
  164. &lt;move todir=&quot;some/new/dir&quot;&gt;
  165. &lt;fileset dir=&quot;my/src/dir&quot;&gt;
  166. &lt;include name=&quot;**/*.jar&quot;/&gt;
  167. &lt;exclude name=&quot;**/ant.jar&quot;/&gt;
  168. &lt;/fileset&gt;
  169. &lt;/move&gt;
  170. </pre>
  171. <p><b>Append <code>&quot;.bak&quot;</code> to the names of all files
  172. in a directory.</b></p>
  173. <pre>
  174. &lt;move todir=&quot;my/src/dir&quot; includeemptydirs=&quot;false&quot;&gt;
  175. &lt;fileset dir=&quot;my/src/dir&quot;&gt;
  176. &lt;exclude name=&quot;**/*.bak&quot;/&gt;
  177. &lt;/fileset&gt;
  178. &lt;mapper type=&quot;glob&quot; from=&quot;*&quot; to=&quot;*.bak&quot;/&gt;
  179. &lt;/move&gt;
  180. </pre>
  181. <hr>
  182. <p align="center">Copyright &copy; 2000-2005 The Apache Software Foundation. All rights
  183. Reserved.</p>
  184. </body>
  185. </html>