You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

touch.html 5.5 KiB

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