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.

sync.html 6.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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>Sync Task</title>
  20. </head>
  21. <body>
  22. <h2><a name="get">Sync</a></h2>
  23. <p><em>Since Ant 1.6</em></p>
  24. <h3>Description</h3>
  25. <p>Synchronize a target directory from the files defined in one or
  26. more <a href="../CoreTypes/resources.html#collection">Resource Collection</a>s.</p>
  27. <p>Any file in the target directory that has not been matched by at
  28. least one of the nested resource collections gets removed. I.e. if you exclude a
  29. file in your sources and a file of that name is present in the target
  30. dir, it will get removed from the target.</p>
  31. <h3>Parameters</h3>
  32. <table border="1" cellpadding="2" cellspacing="0">
  33. <tr>
  34. <td valign="top"><b>Attribute</b></td>
  35. <td valign="top"><b>Description</b></td>
  36. <td align="center" valign="top"><b>Required</b></td>
  37. </tr>
  38. <tr>
  39. <td valign="top">todir</td>
  40. <td valign="top">the target directory to sync with the resource collections</td>
  41. <td align="center" valign="top">Yes</td>
  42. </tr>
  43. <tr>
  44. <td valign="top">overwrite</td>
  45. <td valign="top">Overwrite existing files even if the destination
  46. files are newer.</td>
  47. <td valign="top" align="center">No; defaults to false.</td>
  48. </tr>
  49. <tr>
  50. <td valign="top">includeEmptyDirs</td>
  51. <td valign="top">Copy any empty directories included in the
  52. resource collection(s).<br/>
  53. <b>Note</b> this attribute also controls the behavior for any
  54. nested &lt;preserveintarget&gt; element. If this attribute is
  55. false (the default) empty directories that only exist in the
  56. target directory will be removed even if they are matched by
  57. the patterns of &lt;preserveintarget&gt;. This can be
  58. overridden by &lt;preserveintarget&gt;'s
  59. preserveEmptyDirs attribute.
  60. </td>
  61. <td valign="top" align="center">No; defaults to false.</td>
  62. </tr>
  63. <tr>
  64. <td valign="top">failonerror</td>
  65. <td valign="top">If is set to false, log a warning message, but do not stop the build,
  66. when one of the nested filesets points to a directory that
  67. doesn't exist.
  68. </td>
  69. <td valign="top" align="center">No; defaults to true.</td>
  70. </tr>
  71. <tr>
  72. <td valign="top">verbose</td>
  73. <td valign="top">Log the files that are being copied.</td>
  74. <td valign="top" align="center">No; defaults to false.</td>
  75. </tr>
  76. <tr>
  77. <td valign="top">granularity</td>
  78. <td valign="top">The number of milliseconds leeway to give before
  79. deciding a file is out of date. This is needed because not every
  80. file system supports tracking the last modified time to the
  81. millisecond level. Default is 0 milliseconds, or 2 seconds on DOS
  82. systems. This can also be useful if source and target files live
  83. on separate machines with clocks being out of sync. <em>since Ant
  84. 1.6.2</em>.</td>
  85. <td valign="top" align="center">No.</td>
  86. </tr>
  87. </table>
  88. <h3>Parameters specified as nested elements</h3>
  89. <h4>fileset or any other resource collection</h4>
  90. <p><a href="../CoreTypes/resources.html#collection">Resource
  91. Collection</a>s are used to select groups of files to copy. To use a
  92. resource collection, the <code>todir</code> attribute must be set.</p>
  93. <p>Prior to Ant 1.7 only <code>&lt;fileset&gt;</code> has been
  94. supported as a nested element.</p>
  95. <h4>preserveInTarget</h4>
  96. <p>Specifies files or directories that should be kept in the target
  97. directory even if they are not present in one of the source
  98. directories.</p>
  99. <p>This nested element is like a <a
  100. href="../CoreTypes/fileset.html">FileSet</a> except that it doesn't
  101. support the dir attribute and the usedefaultexcludes attribute
  102. defaults to false.</p>
  103. <h5>Additional Parameters</h5>
  104. <table border="1" cellpadding="2" cellspacing="0">
  105. <tr>
  106. <td valign="top"><b>Attribute</b></td>
  107. <td valign="top"><b>Description</b></td>
  108. <td align="center" valign="top"><b>Required</b></td>
  109. </tr>
  110. <tr>
  111. <td valign="top">preserveEmptyDirs</td>
  112. <td valign="top">Overrules the includeEmptydirs setting for
  113. directories matched by this element. If you want to preserve
  114. empty directories that are not in your source directory you can
  115. either set the task's includeemptydirs attribute or this one.
  116. If the two attribute values conflict, this attribute
  117. "wins".</td>
  118. <td align="center" valign="top">No, defaults to the value of the
  119. task's includeemptydirs attribute</td>
  120. </tr>
  121. </table>
  122. <h3>Examples</h3>
  123. <blockquote><pre>
  124. &lt;sync todir=&quot;site&quot;&gt;
  125. &lt;fileset dir=&quot;generated-site&quot;/&gt;
  126. &lt;/sync&gt;
  127. </pre></blockquote>
  128. <p>overwrites all files in <em>site</em> with newer files from
  129. <em>generated-site</em>, deletes files from <em>site</em> that are not
  130. present in <em>generated-site</em>.</p>
  131. <blockquote><pre>
  132. &lt;sync todir=&quot;site&quot;&gt;
  133. &lt;fileset dir=&quot;generated-site&quot;/&gt;
  134. &lt;preserveintarget&gt;
  135. &lt;include name=&quot;**/CVS/**&quot;/&gt;
  136. &lt;/preserveintarget&gt;
  137. &lt;/sync&gt;
  138. </pre></blockquote>
  139. <p>overwrites all files in <em>site</em> with newer files from
  140. <em>generated-site</em>, deletes files from <em>site</em> that are not
  141. present in <em>generated-site</em> but keeps all files in any
  142. <em>CVS</em> sub-directory.</p>
  143. </body>
  144. </html>