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.

concat.html 7.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Concat</title>
  5. </head>
  6. <body>
  7. <h2><a name="Concat">Concat</a></h2>
  8. <h3>Description</h3>
  9. <p>
  10. Concatenates a file, or a series of files, to a single file or
  11. the console. The destination file will be created if it does
  12. not exist.
  13. </p>
  14. <p>
  15. <a href="../CoreTypes/path.html">Path</a>s and/or
  16. <a href="../CoreTypes/fileset.html">FileSet</a>s and/or <a
  17. href="../CoreTypes/filelist.html">FileList</a>s are used to
  18. select which files are to be concatenated. There is no
  19. singular 'file' attribute to specify a single file to cat.
  20. </p>
  21. <h3>Parameters</h3>
  22. <table border="1" cellpadding="2" cellspacing="0">
  23. <tr>
  24. <td valign="top"><b>Attribute</b></td>
  25. <td valign="top"><b>Description</b></td>
  26. <td align="center" valign="top"><b>Required</b></td>
  27. </tr>
  28. <tr>
  29. <td valign="top">destfile</td>
  30. <td valign="top">
  31. The destination file for the concatenated stream.
  32. If not specified the console will be used instead.
  33. </td>
  34. <td valign="top" align="center">
  35. No
  36. </td>
  37. </tr>
  38. <tr>
  39. <td valign="top">append</td>
  40. <td valign="top">
  41. Specifies whether or not the file specified by 'destfile'
  42. should be appended. Defaults to &quot;no&quot;.
  43. </td>
  44. <td valign="top" align="center">No</td>
  45. </tr>
  46. <tr>
  47. <td valign="top">force</td>
  48. <td valign="top">
  49. Specifies whether or not the file specified by 'destfile'
  50. should be written to even if it is newer than all source files.
  51. <em>since Ant 1.6</em>.
  52. Defaults to &quot;yes&quot;.
  53. </td>
  54. <td valign="top" align="center">No</td>
  55. </tr>
  56. <tr>
  57. <td valign="top">encoding</td>
  58. <td valign="top">
  59. Specifies the encoding for the input files. Please see <a
  60. href="http://java.sun.com/products/jdk/1.2/docs/guide/internat/encoding.doc.html">
  61. http://java.sun.com/products/jdk/1.2/docs/guide/internat/encoding.doc.html</a>
  62. for a list of possible values. Defaults to the platform's
  63. default character encoding.
  64. </td>
  65. <td valign="top" align="center">No</td>
  66. </tr>
  67. </table>
  68. <h3>Parameters specified as nested elements</h3>
  69. <h4>path</h4>
  70. <p><em>since Ant 1.6</em>.</p>
  71. <p>
  72. This is a <a href="../CoreTypes/path.html">Path</a>. This is
  73. used to select file files to be concatenated. Note that
  74. if a file can only appear once in a path. If this is
  75. an issue consider using multiple paths.
  76. </p>
  77. <h4>fileset</h4>
  78. <p>
  79. <a href="../CoreTypes/fileset.html">FileSet</a>s are used to
  80. select files to be concatenated. Note that the order in which
  81. the files selected from a fileset are concatenated is
  82. <i>not</i> guaranteed. If this is an issue, use multiple
  83. filesets or consider using filelists.
  84. </p>
  85. <h4>filelist</h4>
  86. <p>
  87. <a href="../CoreTypes/filelist.html">FileList</a>s are used to
  88. select files to be concatenated. The file ordering in the
  89. <var>files</var> attribute will be the same order in which the
  90. files are concatenated.
  91. </p>
  92. <h4>filterchain</h4>
  93. <p><em>since Ant 1.6</em>.</p>
  94. <p>The concat task supports nested
  95. <a href="../CoreTypes/filterchain.html"> FilterChain</a>s.</p>
  96. <h4>header,footer</h4>
  97. <p><em>since Ant 1.6</em>.</p>
  98. <p>Used to prepend or postpend text into the concatenated stream.</p>
  99. <p>The text may be in-line or be in a file.</p>
  100. <table border="1" cellpadding="2" cellspacing="0">
  101. <tr>
  102. <td valign="top"><b>Attribute</b></td>
  103. <td valign="top"><b>Description</b></td>
  104. <td align="center" valign="top"><b>Required</b></td>
  105. </tr>
  106. <tr>
  107. <td valign="top">filtering</td>
  108. <td valign="top">
  109. Whether to filter the text provided by this sub element,
  110. default is "yes".
  111. <td valign="top" align = "center">No</td>
  112. </tr>
  113. <tr>
  114. <td valign="top">file</td>
  115. <td valign="top">A file to place at the head or tail of the
  116. concatenated text.
  117. <td valign="top" align = "center">No</td>
  118. </tr>
  119. <tr>
  120. <td valign="top">trim</td>
  121. <td valign="top">Whether to trim the value, default is "no"</td>
  122. <td valign="top" align = "center">No</td>
  123. </tr>
  124. <tr>
  125. <td valign="top">trimleading</td>
  126. <td valign="top">
  127. Whether to trim leading white space on each line, default is "no"
  128. </td>
  129. <td valign="top" align = "center">No</td>
  130. </tr>
  131. </table>
  132. <h3>Examples</h3>
  133. <p><b>Concatenate a string to a file:</b></p>
  134. <pre>
  135. &lt;concat destfile=&quot;README&quot;&gt;Hello, World!&lt;/concat&gt;
  136. </pre>
  137. <p><b>Concatenate a series of files to the console:</b></p>
  138. <pre>
  139. &lt;concat&gt;
  140. &lt;fileset dir=&quot;messages&quot; includes=&quot;*important*&quot;/&gt;
  141. &lt;/concat&gt;
  142. </pre>
  143. <p><b>Concatenate a single file, appending if the destination file exists:</b></p>
  144. <pre>
  145. &lt;concat destfile=&quot;NOTES&quot; append=&quot;true&quot;&gt;
  146. &lt;filelist dir=&quot;notes&quot; files=&quot;note.txt&quot;/&gt;
  147. &lt;/concat&gt;
  148. </pre>
  149. <p><b>Concatenate a series of files, update the destination
  150. file only if is older that all the source files:</b></p>
  151. <pre>
  152. &lt;concat destfile=&quot;${docbook.dir}/all-sections.xml&quot;
  153. force=&quot;no&quot;&gt;
  154. &lt;filelist dir=&quot;${docbook.dir}/sections&quot;
  155. files=&quot;introduction.xml,overview.xml&quot;/&gt;
  156. &lt;fileset dir=&quot;${docbook.dir}&quot;
  157. includes=&quot;sections/*.xml&quot;
  158. excludes=&quot;introduction.xml,overview.xml&quot;/&gt;
  159. &lt;/concat&gt;
  160. </pre>
  161. <p><b>Concatenate a series of files, expanding ant properties</b></p>
  162. <pre>
  163. &lt;concat destfile="${build.dir}/subs"&gt;
  164. &lt;path&gt;
  165. &lt;fileset dir="${src.dir}" includes="*.xml"/&gt;
  166. &lt;pathelement location="build.xml"/&gt;
  167. &lt;/path&gt;
  168. &lt;filterchain&gt;
  169. &lt;expandproperties/&gt;
  170. &lt;/filterchain&gt;
  171. &lt;/concat&gt;
  172. </pre>
  173. <p><b>Filter the lines containing project from build.xml and output
  174. them to report.output, prepending with a header</b></p>
  175. <pre>
  176. &lt;concat destfile="${build.dir}/report.output"&gt;
  177. &lt;header filtering="no" trimleading="yes"&gt;
  178. Lines that contain project
  179. ==========================
  180. &lt;/header&gt;
  181. &lt;path path="build.xml"/&gt;
  182. &lt;filterchain&gt;
  183. &lt;linecontains&gt;
  184. &lt;contains value="project"/&gt;
  185. &lt;/linecontains&gt;
  186. &lt;/filterchain&gt;
  187. &lt;/concat&gt;
  188. </pre>
  189. <hr>
  190. <p align="center">
  191. Copyright &copy; 2002-2003 Apache Software Foundation. All
  192. Rights Reserved.
  193. </p>
  194. </body>
  195. </html>