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 |
|
---|
9 | http://www.apache.org/licenses/LICENSE-2.0
|
---|
10 |
|
---|
11 | Unless required by applicable law or agreed to in writing, software
|
---|
12 | distributed under the License is distributed on an "AS IS" BASIS,
|
---|
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
14 | See the License for the specific language governing permissions and
|
---|
15 | limitations under the License.
|
---|
16 | -->
|
---|
17 | <html>
|
---|
18 |
|
---|
19 | <head>
|
---|
20 | <meta http-equiv="Content-Language" content="en-us">
|
---|
21 | <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
|
---|
22 | <title>Move Task</title>
|
---|
23 | </head>
|
---|
24 |
|
---|
25 | <body>
|
---|
26 |
|
---|
27 | <h2><a name="move">Move</a></h2>
|
---|
28 | <h3>Description</h3>
|
---|
29 | <p>Moves a file to a new file or directory, or collections of files to
|
---|
30 | a new directory. By default, the
|
---|
31 | destination file is overwritten if it already exists. When <var>overwrite</var> is
|
---|
32 | turned off, then files are only moved if the source file is newer than
|
---|
33 | the destination file, or when the destination file does not exist.</p>
|
---|
34 |
|
---|
35 | <p><a href="../CoreTypes/resources.html#collection">Resource
|
---|
36 | Collection</a>s are used to select a group of files to move. Only
|
---|
37 | file system based resource collections are supported, this includes <a
|
---|
38 | href="../CoreTypes/fileset.html">fileset</a>s, <a
|
---|
39 | href="../CoreTypes/filelist.html">filelist</a> and <a
|
---|
40 | href="../using.html#path">path</a>. Prior to Ant 1.7 only
|
---|
41 | <code><fileset></code> has been supported as a nested element.
|
---|
42 | To use a resource collection, the <code>todir</code> attribute must be
|
---|
43 | set.</p>
|
---|
44 |
|
---|
45 | <p><b>Since Ant 1.6.3</b>, the <i>file</i> attribute may be used to move
|
---|
46 | (rename) an entire directory. If <i>tofile</i> denotes an existing file, or
|
---|
47 | there is a directory by the same name in <i>todir</i>, the action will fail.
|
---|
48 | </p>
|
---|
49 | <h3>Parameters</h3>
|
---|
50 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
51 | <tr>
|
---|
52 | <td valign="top"><b>Attribute</b></td>
|
---|
53 | <td valign="top"><b>Description</b></td>
|
---|
54 | <td align="center" valign="top"><b>Required</b></td>
|
---|
55 | </tr>
|
---|
56 | <tr>
|
---|
57 | <td valign="top">file</td>
|
---|
58 | <td valign="top">the file or directory to move</td>
|
---|
59 | <td valign="top" align="center">One of <var>file</var> or
|
---|
60 | at least one nested resource collection element</td>
|
---|
61 | </tr>
|
---|
62 | <tr>
|
---|
63 | <td valign="top">preservelastmodified</td>
|
---|
64 | <td valign="top">Give the moved files the same last modified
|
---|
65 | time as the original source files.
|
---|
66 | (<em>Note</em>: Ignored on Java 1.1)</td>
|
---|
67 | <td valign="top" align="center">No; defaults to false.</td>
|
---|
68 | </tr>
|
---|
69 | <tr>
|
---|
70 | <td valign="top">tofile</td>
|
---|
71 | <td valign="top">the file to move to</td>
|
---|
72 | <td valign="top" align="center" rowspan="2">With the <var>file</var> attribute,
|
---|
73 | either <var>tofile</var> or <var>todir</var> can be used. With nested filesets,
|
---|
74 | if the fileset size is greater than 1 or if the only entry in the fileset is a
|
---|
75 | directory or if the <var>file</var> attribute is already specified, only
|
---|
76 | <var>todir</var> is allowed</td>
|
---|
77 | </tr>
|
---|
78 | <tr>
|
---|
79 | <td valign="top">todir</td>
|
---|
80 | <td valign="top">the directory to move to</td>
|
---|
81 | </tr>
|
---|
82 | <tr>
|
---|
83 | <td valign="top">overwrite</td>
|
---|
84 | <td valign="top">overwrite existing files even if the destination
|
---|
85 | files are newer (default is "true")</td>
|
---|
86 | <td valign="top" align="center">No</td>
|
---|
87 | </tr>
|
---|
88 | <tr>
|
---|
89 | <td valign="top">filtering</td>
|
---|
90 | <td valign="top">indicates whether token filtering should take place during
|
---|
91 | the move. See the <a href="filter.html">filter</a> task for a description of
|
---|
92 | how filters work.</td>
|
---|
93 | <td valign="top" align="center">No</td>
|
---|
94 | </tr>
|
---|
95 | <tr>
|
---|
96 | <td valign="top">flatten</td>
|
---|
97 | <td valign="top">ignore directory structure of source directory,
|
---|
98 | copy all files into a single directory, specified by the <var>todir</var>
|
---|
99 | attribute (default is "false").Note that you can achieve the
|
---|
100 | same effect by using a <a href="../CoreTypes/mapper.html#flatten-mapper">flatten mapper</a></td>
|
---|
101 | <td valign="top" align="center">No</td>
|
---|
102 | </tr>
|
---|
103 | <tr>
|
---|
104 | <td valign="top">includeEmptyDirs</td>
|
---|
105 | <td valign="top">Copy empty directories included with the nested FileSet(s).
|
---|
106 | Defaults to "yes".</td>
|
---|
107 | <td valign="top" align="center">No</td>
|
---|
108 | </tr>
|
---|
109 | <tr>
|
---|
110 | <td valign="top">failonerror</td>
|
---|
111 | <td valign="top">If false, log a warning message, but do not stop the
|
---|
112 | build, when the file to copy does not exist or one of the nested
|
---|
113 | filesets points to a directory that doesn't exist or an error occurs
|
---|
114 | while moving.
|
---|
115 | </td>
|
---|
116 | <td valign="top" align="center">No; defaults to true.</td>
|
---|
117 | </tr>
|
---|
118 | <tr>
|
---|
119 | <td valign="top">verbose</td>
|
---|
120 | <td valign="top">Log the files that are being moved.</td>
|
---|
121 | <td valign="top" align="center">No; defaults to false.</td>
|
---|
122 | </tr>
|
---|
123 | <tr>
|
---|
124 | <td valign="top">encoding</td>
|
---|
125 | <td valign="top">The encoding to assume when filter-copying the
|
---|
126 | files. <em>since Ant 1.5</em>.</td>
|
---|
127 | <td align="center">No - defaults to default JVM encoding</td>
|
---|
128 | </tr>
|
---|
129 | <tr>
|
---|
130 | <td valign="top">outputencoding</td>
|
---|
131 | <td valign="top">The encoding to use when writing the files.
|
---|
132 | <em>since Ant 1.6</em>.</td>
|
---|
133 | <td align="center">No - defaults to the value of the encoding
|
---|
134 | attribute if given or the default JVM encoding otherwise.</td>
|
---|
135 | </tr>
|
---|
136 | <tr>
|
---|
137 | <td valign="top">enablemultiplemapping</td>
|
---|
138 | <td valign="top">
|
---|
139 | If true the task will process to all the mappings for a
|
---|
140 | given source path. If false the task will only process
|
---|
141 | the first file or directory. This attribute is only relevant
|
---|
142 | if there is a mapper subelement.
|
---|
143 | <em>since Ant 1.6</em>.</td>
|
---|
144 | <td align="center">No - defaults to false.</td>
|
---|
145 | </tr>
|
---|
146 | <tr>
|
---|
147 | <td valign="top">granularity</td>
|
---|
148 | <td valign="top">The number of milliseconds leeway to give before
|
---|
149 | deciding a file is out of date. This is needed because not every
|
---|
150 | file system supports tracking the last modified time to the
|
---|
151 | millisecond level. Default is 0 milliseconds, or 2 seconds on DOS
|
---|
152 | systems. This can also be useful if source and target files live
|
---|
153 | on separate machines with clocks being out of sync. <em>since Ant
|
---|
154 | 1.6</em>.</td>
|
---|
155 | </tr>
|
---|
156 | </table>
|
---|
157 | <h3>Parameters specified as nested elements</h3>
|
---|
158 | <h4>mapper</h4>
|
---|
159 | <p>You can define file name transformations by using a nested <a
|
---|
160 | href="../CoreTypes/mapper.html">mapper</a> element. The default mapper used by
|
---|
161 | <code><move></code> is the <a
|
---|
162 | href="../CoreTypes/mapper.html#identity-mapper">identity</a>.</p>
|
---|
163 | <p>Note that the source name handed to the mapper depends on the
|
---|
164 | resource collection you use. If you use <code><fileset></code>
|
---|
165 | or any other collection that provides a base directory, the name
|
---|
166 | passed to the mapper will be a relative filename, relative to the base
|
---|
167 | directory. In any other case the absolute filename of the source will
|
---|
168 | be used.</p>
|
---|
169 | <h4>filterchain</h4>
|
---|
170 | <p>The Move task supports nested <a href="../CoreTypes/filterchain.html">
|
---|
171 | FilterChain</a>s.</p>
|
---|
172 |
|
---|
173 | <p>
|
---|
174 | If <code><filterset></code> and <code><filterchain></code> elements are used inside the
|
---|
175 | same <code><move></code> task, all <code><filterchain></code> elements are processed first
|
---|
176 | followed by <code><filterset></code> elements.
|
---|
177 | </p>
|
---|
178 |
|
---|
179 | <h3>Examples</h3>
|
---|
180 | <p><b>Move a single file (rename a file)</b></p>
|
---|
181 | <pre>
|
---|
182 | <move file="file.orig" tofile="file.moved"/>
|
---|
183 | </pre>
|
---|
184 | <p><b>Move a single file to a directory</b></p>
|
---|
185 | <pre>
|
---|
186 | <move file="file.orig" todir="dir/to/move/to"/>
|
---|
187 | </pre>
|
---|
188 | <p><b>Move a directory to a new directory</b></p>
|
---|
189 | <pre>
|
---|
190 | <move todir="new/dir/to/move/to">
|
---|
191 | <fileset dir="src/dir"/>
|
---|
192 | </move>
|
---|
193 | </pre>
|
---|
194 | <i>or, since Ant 1.6.3:</i>
|
---|
195 | <pre>
|
---|
196 | <move file="src/dir" tofile="new/dir/to/move/to"/>
|
---|
197 | </pre>
|
---|
198 | <p><b>Move a set of files to a new directory</b></p>
|
---|
199 | <pre>
|
---|
200 | <move todir="some/new/dir">
|
---|
201 | <fileset dir="my/src/dir">
|
---|
202 | <include name="**/*.jar"/>
|
---|
203 | <exclude name="**/ant.jar"/>
|
---|
204 | </fileset>
|
---|
205 | </move>
|
---|
206 | </pre>
|
---|
207 | <p><b>Move a list of files to a new directory</b></p>
|
---|
208 | <pre>
|
---|
209 | <move todir="some/new/dir">
|
---|
210 | <filelist dir="my/src/dir">
|
---|
211 | <file name="file1.txt"/>
|
---|
212 | <file name="file2.txt"/>
|
---|
213 | </filelist>
|
---|
214 | </move>
|
---|
215 | </pre>
|
---|
216 | <p><b>Append <code>".bak"</code> to the names of all files
|
---|
217 | in a directory.</b></p>
|
---|
218 | <pre>
|
---|
219 | <move todir="my/src/dir" includeemptydirs="false">
|
---|
220 | <fileset dir="my/src/dir">
|
---|
221 | <exclude name="**/*.bak"/>
|
---|
222 | </fileset>
|
---|
223 | <mapper type="glob" from="*" to="*.bak"/>
|
---|
224 | </move>
|
---|
225 | </pre>
|
---|
226 |
|
---|
227 |
|
---|
228 | </body>
|
---|
229 | </html>
|
---|
230 |
|
---|