2001-02-13 12:32:01 +00:00
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Language" content="en-us">
|
2001-12-04 03:06:04 +00:00
|
|
|
<title>Copy Task</title>
|
2001-02-13 12:32:01 +00:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<h2><a name="copy">Copy</a></h2>
|
|
|
|
<h3>Description</h3>
|
|
|
|
<p>Copies a file or Fileset to a new file or directory. Files are
|
|
|
|
only copied if the source file is newer than the destination file,
|
|
|
|
or when the destination file does not exist. However, you can explicitly
|
|
|
|
overwrite files with the <var>overwrite</var> attribute.</p>
|
|
|
|
<p><a href="../CoreTypes/fileset.html">FileSet</a>s are used to select files to copy.
|
|
|
|
To use a fileset, the <var>todir</var> attribute must be set.</p>
|
|
|
|
<h3>Parameters</h3>
|
|
|
|
<table border="1" cellpadding="2" cellspacing="0">
|
|
|
|
<tr>
|
|
|
|
<td valign="top"><b>Attribute</b></td>
|
|
|
|
<td valign="top"><b>Description</b></td>
|
|
|
|
<td align="center" valign="top"><b>Required</b></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">file</td>
|
|
|
|
<td valign="top">The file to copy.</td>
|
|
|
|
<td valign="top" align="center">One of either <var>file</var> or
|
|
|
|
at least one nested fileset element.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">preservelastmodified</td>
|
|
|
|
<td valign="top">Give the copied files the same last modified
|
|
|
|
time as the original files. Defaults to "no".</td>
|
|
|
|
<td valign="top" align="center">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">tofile</td>
|
|
|
|
<td valign="top">The file to copy to.</td>
|
|
|
|
<td valign="top" align="center" rowspan="2">With the <var>file</var> attribute,
|
|
|
|
either <var>tofile</var> or <var>todir</var> can be used. With nested filesets,
|
2001-10-12 08:19:40 +00:00
|
|
|
if the fileset size is greater than 1 or if the only entry in the fileset is a
|
|
|
|
directory or if the file attribute is already specified, only
|
|
|
|
<var>todir</var> is allowed</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">todir</td>
|
|
|
|
<td valign="top">The directory to copy to.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">overwrite</td>
|
|
|
|
<td valign="top">Overwrite existing files even if the destination
|
|
|
|
files are newer. Defaults to "no".</td>
|
|
|
|
<td valign="top" align="center">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">filtering</td>
|
2001-08-30 13:23:14 +00:00
|
|
|
<td valign="top">Indicates whether token filtering using the global build file
|
|
|
|
filters should take place during the copy. Defaults to "no".
|
|
|
|
Nested filtersets will be used even if this value is "no"</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
<td valign="top" align="center">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">flatten</td>
|
|
|
|
<td valign="top">Ignore directory structure of source directory,
|
|
|
|
copy all files into a single directory, specified by the <var>todir</var>
|
|
|
|
attribute. Defaults to "no". Note that you can achieve the
|
|
|
|
same effect by using a <a href="../CoreTypes/mapper.html#flatten-mapper">flatten mapper</a></td>
|
|
|
|
<td valign="top" align="center">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">includeEmptyDirs</td>
|
2001-12-04 03:06:04 +00:00
|
|
|
<td valign="top">Copy empty directories included with the nested FileSet(s).
|
|
|
|
Defaults to "yes".</td>
|
|
|
|
<td valign="top" align="center">No</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<h3>Parameters specified as nested elements</h3>
|
2001-08-30 13:23:14 +00:00
|
|
|
|
|
|
|
<h4>fileset</h4>
|
|
|
|
<p><a href="../CoreTypes/fileset.html">FileSets</a> are used to select files to copy.
|
|
|
|
To use a fileset, the <var>todir</var> attribute must be set.</p>
|
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<h4>mapper</h4>
|
2001-08-30 13:23:14 +00:00
|
|
|
<p>You can define file name transformations by using a nested <a
|
|
|
|
href="../CoreTypes/mapper.html">mapper</a> element. The default mapper used by
|
|
|
|
<code><copy></code> is the <a
|
|
|
|
href="../CoreTypes/mapper.html#identity-mapper">identity</a>.</p>
|
|
|
|
|
|
|
|
<h4>filterset</h4>
|
|
|
|
<p><a href="../CoreTypes/filterset.html">Filtersets</a> are used to replace tokens in files that are copied.
|
|
|
|
To use a filterset just add the nested filterset elements.</P>
|
|
|
|
|
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<h3>Examples</h3>
|
|
|
|
<p><b>Copy a single file</b></p>
|
|
|
|
<pre>
|
|
|
|
<copy file="myfile.txt" tofile="mycopy.txt"/>
|
|
|
|
</pre>
|
|
|
|
<p><b>Copy a file to a directory</b></p>
|
|
|
|
<pre>
|
|
|
|
<copy file="myfile.txt" todir="../some/dir/tree"/>
|
|
|
|
</pre>
|
|
|
|
<p><b>Copy a directory to another directory</b></p>
|
|
|
|
<pre>
|
|
|
|
<copy todir="../new/dir">
|
|
|
|
<fileset dir="src_dir"/>
|
|
|
|
</copy>
|
|
|
|
</pre>
|
|
|
|
<p><b>Copy a set of files to a directory</b></p>
|
|
|
|
<pre>
|
|
|
|
<copy todir="../dest/dir" >
|
2001-12-04 03:06:04 +00:00
|
|
|
<fileset dir="src_dir" >
|
2001-02-13 12:32:01 +00:00
|
|
|
<exclude name="**/*.java"/>
|
|
|
|
</fileset>
|
|
|
|
</copy>
|
|
|
|
|
|
|
|
<copy todir="../dest/dir" >
|
2001-12-04 03:06:04 +00:00
|
|
|
<fileset dir="src_dir" excludes="**/*.java"/>
|
2001-02-13 12:32:01 +00:00
|
|
|
</copy>
|
|
|
|
</pre>
|
|
|
|
<p><b>Copy a set of files to a directory appending
|
|
|
|
"<code>.bak</code>" to the file name on the fly</b></p>
|
|
|
|
<pre>
|
|
|
|
<copy todir="../backup/dir" >
|
2001-12-04 03:06:04 +00:00
|
|
|
<fileset dir="src_dir" />
|
2001-02-13 12:32:01 +00:00
|
|
|
<mapper type="glob" from="*" to="*.bak"/>
|
|
|
|
</copy>
|
|
|
|
</pre>
|
2001-08-30 13:23:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
<p><b>Copy a set of files to a replacing @TITLE@ with Foo Bar in all files.</b></p>
|
|
|
|
<pre>
|
|
|
|
<copy todir="../backup/dir" >
|
|
|
|
<fileset dir="src_dir" />
|
|
|
|
<filterset>
|
|
|
|
<filter token="TITLE" value="Foo Bar" />
|
|
|
|
</filterset>
|
|
|
|
</copy>
|
|
|
|
</pre>
|
|
|
|
|
2001-12-04 03:06:04 +00:00
|
|
|
<p><strong>Unix Note:</strong> file permissions are not retained when files
|
|
|
|
are copied; they end up with the default UMASK permissions instead. This
|
|
|
|
is caused by the lack of any means to query or set file permissions in the
|
|
|
|
current Java runtimes. If you need a permission preserving copy function,
|
|
|
|
use <exec executable="cp" ... > instead.
|
2001-08-30 13:23:14 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<hr><p align="center">Copyright © 2000,2001 Apache Software Foundation. All rights
|
|
|
|
Reserved.</p>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|