source: other-projects/trunk/realistic-books/packages/AntInstaller/web/manual1.7.0/manual/CoreTasks/touch.html@ 19253

Last change on this file since 19253 was 19253, checked in by davidb, 15 years ago

Establishing a source code repository for Veronica's Realistic Book's software

File size: 5.5 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>Touch Task</title>
23</head>
24
25<body>
26
27<h2><a name="touch">Touch</a></h2>
28<h3>Description</h3>
29
30<p>Changes the modification time of a resource and possibly creates it
31at the same time. In addition to working with a single file, this Task
32can also work on <a href="../CoreTypes/resource.html">resource</a> and
33resource collections (which also includes directories). Prior to Ant
341.7 only FileSet or <a href="../CoreTypes/filelist.html">Filelist</a>
35(since Ant 1.6) have been supported.</p>
36
37<h3>Parameters</h3>
38<table border="1" cellpadding="2" cellspacing="0">
39 <tr>
40 <td valign="top"><b>Attribute</b></td>
41 <td valign="top"><b>Description</b></td>
42 <td align="center" valign="top"><b>Required</b></td>
43 </tr>
44 <tr>
45 <td valign="top">file</td>
46 <td valign="top">The name of the file.</td>
47 <td valign="top" align="center">Unless a nested resource collection element
48 has been specified.</td>
49 </tr>
50 <tr>
51 <td valign="top">millis</td>
52 <td valign="top">Specifies the new modification time of the file
53 in milliseconds since midnight Jan 1 1970.</td>
54 <td valign="center" align="center" rowspan="2">No--datetime takes
55 precedence, however if both are omitted the current time is assumed.</td>
56 </tr>
57 <tr>
58 <td valign="top">datetime</td>
59 <td valign="top">Specifies the new modification time of the file.</td>
60 </tr>
61 <tr>
62 <td valign="top">pattern</td>
63 <td valign="top">SimpleDateFormat-compatible pattern string.
64 Defaults to MM/DD/YYYY HH:MM AM_or_PM or MM/DD/YYYY HH:MM:SS AM_or_PM.
65 <b>Since Ant 1.6.3</b></td>
66 <td valign="top" align="center">No</td>
67 </tr>
68 <tr>
69 <td valign="top">mkdirs</td>
70 <td valign="top">Whether to create nonexistent parent
71 directories when touching new files. <b>Since Ant 1.6.3</b></td>
72 <td valign="top" align="center">No, default <i>false</i>.</td>
73 </tr>
74 <tr>
75 <td valign="top">verbose</td>
76 <td valign="top">Whether to log the creation of new files.
77 <b>Since Ant 1.6.3</b></td>
78 <td valign="top" align="center">No, default <i>true</i>.</td>
79 </tr>
80</table>
81<h3>Parameters specified as nested elements</h3>
82<h4>any resource collection</h4>
83
84<p>You can use any number of nested resource collection elements to
85define the resource for this task and refer to resources defined
86elsewhere. <b>Note:</b> resource passed to this task must implement
87the <code>org.apache.tools.ant.types.resources.Touchable</code>
88interface, this is true for all filesystem-based resources like those
89returned by path, fileset ot filelist.</p>
90
91<p>For backwards compatibility directories matched by nested filesets
92will be "touched" as well, use a &lt;type&gt; selector to suppress
93this. This only applies to filesets nested into the task directly,
94not to filesets nested into a path or any other resource
95collection.</p>
96
97<h4>mapper</h4>
98<p><em>Since Ant 1.6.3,</em> a nested <a href="../CoreTypes/mapper.html">
99 mapper</a> can be specified. Files specified via nested
100 <code>fileset</code>s, <code>filelist</code>s, or the <code>file</code>
101 attribute are mapped using the specified mapper. For each file mapped,
102 the resulting files are touched. If the original file exists its
103 timestamp will be used. Otherwise the task settings (<code>millis</code>,
104 <code>datetime</code>) take effect.</p>
105<h3>Examples</h3>
106<pre> &lt;touch file=&quot;myfile&quot;/&gt;</pre>
107<p>creates <code>myfile</code> if it doesn't exist and changes the
108modification time to the current time.</p>
109<pre> &lt;touch file=&quot;myfile&quot; datetime=&quot;06/28/2000 2:02 pm&quot;/&gt;</pre>
110<p>creates <code>myfile</code> if it doesn't exist and changes the
111modification time to Jun, 28 2000 2:02 pm (14:02 for those used to 24
112hour times).</p>
113<pre> &lt;touch datetime=&quot;09/10/1974 4:30 pm&quot;&gt;
114 &lt;fileset dir=&quot;src_dir&quot;/&gt;
115 &lt;/touch&gt;</pre>
116<p>changes the modification time to Oct, 09 1974 4:30 pm of all files and directories
117 found in <code>src_dir</code>. </p>
118<pre> &lt;touch file=&quot;myfile&quot; datetime=&quot;06/28/2000 2:02:17 pm&quot;/&gt;</pre>
119<p>creates <code>myfile</code> if it doesn't exist and changes the
120modification time to Jun, 28 2000 2:02:17 pm (14:02:17 for those used to 24
121hour times), if the filesystem allows a precision of one second - a
122time close to it otherwise.</p>
123<pre> &lt;touch file=&quot;foo&quot;&gt;
124 &lt;mapper type=&quot;glob&quot; from=&quot;foo&quot; to=&quot;bar&quot; /&gt;
125 &lt;/touch&gt;
126</pre>
127<p>creates <code>bar</code> if it doesn't exist and changes the
128modification time to that of <code>foo</code>.</p>
129
130
131</body>
132</html>
Note: See TracBrowser for help on using the repository browser.