source: release-kits/lirk3/bin/ant-installer/web/manual/manual/CoreTasks/move.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 8.9 KB
Line 
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
30a new directory. By default, the
31destination file is overwritten if it already exists. When <var>overwrite</var> is
32turned off, then files are only moved if the source file is newer than
33the destination file, or when the destination file does not exist.</p>
34
35<p><a href="../CoreTypes/resources.html#collection">Resource
36Collection</a>s are used to select a group of files to move. Only
37file system based resource collections are supported, this includes <a
38href="../CoreTypes/fileset.html">fileset</a>s, <a
39href="../CoreTypes/filelist.html">filelist</a> and <a
40href="../using.html#path">path</a>. Prior to Ant 1.7 only
41<code>&lt;fileset&gt;</code> has been supported as a nested element.
42To use a resource collection, the <code>todir</code> attribute must be
43set.</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
47there 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 &quot;true&quot;)</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 &quot;false&quot;).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 &quot;yes&quot;.</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
160href="../CoreTypes/mapper.html">mapper</a> element. The default mapper used by
161<code>&lt;move&gt;</code> is the <a
162href="../CoreTypes/mapper.html#identity-mapper">identity</a>.</p>
163<p>Note that the source name handed to the mapper depends on the
164resource collection you use. If you use <code>&lt;fileset&gt;</code>
165or any other collection that provides a base directory, the name
166passed to the mapper will be a relative filename, relative to the base
167directory. In any other case the absolute filename of the source will
168be used.</p>
169<h4>filterchain</h4>
170<p>The Move task supports nested <a href="../CoreTypes/filterchain.html">
171FilterChain</a>s.</p>
172
173<p>
174If <code>&lt;filterset&gt;</code> and <code>&lt;filterchain&gt;</code> elements are used inside the
175same <code>&lt;move&gt;</code> task, all <code>&lt;filterchain&gt;</code> elements are processed first
176followed by <code>&lt;filterset&gt;</code> elements.
177</p>
178
179<h3>Examples</h3>
180<p><b>Move a single file (rename a file)</b></p>
181<pre>
182 &lt;move file=&quot;file.orig&quot; tofile=&quot;file.moved&quot;/&gt;
183</pre>
184<p><b>Move a single file to a directory</b></p>
185<pre>
186 &lt;move file=&quot;file.orig&quot; todir=&quot;dir/to/move/to&quot;/&gt;
187</pre>
188<p><b>Move a directory to a new directory</b></p>
189<pre>
190 &lt;move todir=&quot;new/dir/to/move/to&quot;&gt;
191 &lt;fileset dir=&quot;src/dir&quot;/&gt;
192 &lt;/move&gt;
193</pre>
194 <i>or, since Ant 1.6.3:</i>
195<pre>
196 &lt;move file=&quot;src/dir&quot; tofile=&quot;new/dir/to/move/to&quot;/&gt;
197</pre>
198<p><b>Move a set of files to a new directory</b></p>
199<pre>
200 &lt;move todir=&quot;some/new/dir&quot;&gt;
201 &lt;fileset dir=&quot;my/src/dir&quot;&gt;
202 &lt;include name=&quot;**/*.jar&quot;/&gt;
203 &lt;exclude name=&quot;**/ant.jar&quot;/&gt;
204 &lt;/fileset&gt;
205 &lt;/move&gt;
206</pre>
207<p><b>Move a list of files to a new directory</b></p>
208<pre>
209 &lt;move todir=&quot;some/new/dir&quot;&gt;
210 &lt;filelist dir=&quot;my/src/dir&quot;&gt;
211 &lt;file name="file1.txt"/&gt;
212 &lt;file name="file2.txt"/&gt;
213 &lt;/filelist&gt;
214 &lt;/move&gt;
215</pre>
216<p><b>Append <code>&quot;.bak&quot;</code> to the names of all files
217in a directory.</b></p>
218<pre>
219 &lt;move todir=&quot;my/src/dir&quot; includeemptydirs=&quot;false&quot;&gt;
220 &lt;fileset dir=&quot;my/src/dir&quot;&gt;
221 &lt;exclude name=&quot;**/*.bak&quot;/&gt;
222 &lt;/fileset&gt;
223 &lt;mapper type=&quot;glob&quot; from=&quot;*&quot; to=&quot;*.bak&quot;/&gt;
224 &lt;/move&gt;
225</pre>
226
227
228</body>
229</html>
230
Note: See TracBrowser for help on using the repository browser.