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