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 8.8 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. <tr>
  68. <td valign="top">outputencoding</td>
  69. <td valign="top">
  70. The encoding to use when writing the output file
  71. <em>since Ant 1.6</em>.
  72. Defaults to the value of the encoding attribute
  73. if given or the default JVM encoding otherwise.
  74. </td>
  75. <td valign="top" align="center">No</td>
  76. </tr>
  77. <tr>
  78. <td valign="top">fixlastline</td>
  79. <td valign="top">
  80. Specifies whether or not to check if
  81. each file concatenated is terminated by
  82. a new line. If this attribute is &quot;yes&quot;
  83. a new line will be appended to the stream if
  84. the file did not end in a new line.
  85. <em>since Ant 1.6</em>.
  86. Defaults to &quot;no&quot;.
  87. This attribute does not apply to embedded text.
  88. </td>
  89. <td valign="top" align="center">No</td>
  90. </tr>
  91. <tr>
  92. <td valign="top">eol</td>
  93. <td valign="top">
  94. Specifies what the end of line character are
  95. for use by the fixlastline attribute.
  96. <em>since Ant 1.6</em>
  97. Valid values for this property are:
  98. <ul>
  99. <li>cr: a single CR</li>
  100. <li>lf: a single LF</li>
  101. <li>crlf: the pair CRLF</li>
  102. <li>mac: a single CR</li>
  103. <li>unix: a single LF</li>
  104. <li>dos: the pair CRLF</li>
  105. </ul>
  106. The default is platform dependent.
  107. For Unix platforms, the default is &quot;lf&quot;.
  108. For DOS based systems (including Windows),
  109. the default is &quot;crlf&quot;.
  110. For Mac OS, the default is &quot;cr&quot;.
  111. </td>
  112. <td valign="top" align="center">No</td>
  113. </tr>
  114. </table>
  115. <h3>Parameters specified as nested elements</h3>
  116. <h4>path</h4>
  117. <p><em>since Ant 1.6</em>.</p>
  118. <p>
  119. This is a <a href="../CoreTypes/path.html">Path</a>. This is
  120. used to select file files to be concatenated. Note that
  121. a file can only appear once in a path. If this is
  122. an issue consider using multiple paths.
  123. </p>
  124. <h4>fileset</h4>
  125. <p>
  126. <a href="../CoreTypes/fileset.html">FileSet</a>s are used to
  127. select files to be concatenated. Note that the order in which
  128. the files selected from a fileset are concatenated is
  129. <i>not</i> guaranteed. If this is an issue, use multiple
  130. filesets or consider using filelists.
  131. </p>
  132. <h4>filelist</h4>
  133. <p>
  134. <a href="../CoreTypes/filelist.html">FileList</a>s are used to
  135. select files to be concatenated. The file ordering in the
  136. <var>files</var> attribute will be the same order in which the
  137. files are concatenated.
  138. </p>
  139. <h4>filterchain</h4>
  140. <p><em>since Ant 1.6</em>.</p>
  141. <p>The concat task supports nested
  142. <a href="../CoreTypes/filterchain.html"> FilterChain</a>s.</p>
  143. <h4>header,footer</h4>
  144. <p><em>since Ant 1.6</em>.</p>
  145. <p>Used to prepend or postpend text into the concatenated stream.</p>
  146. <p>The text may be in-line or be in a file.</p>
  147. <table border="1" cellpadding="2" cellspacing="0">
  148. <tr>
  149. <td valign="top"><b>Attribute</b></td>
  150. <td valign="top"><b>Description</b></td>
  151. <td align="center" valign="top"><b>Required</b></td>
  152. </tr>
  153. <tr>
  154. <td valign="top">filtering</td>
  155. <td valign="top">
  156. Whether to filter the text provided by this sub element,
  157. default is "yes".
  158. <td valign="top" align = "center">No</td>
  159. </tr>
  160. <tr>
  161. <td valign="top">file</td>
  162. <td valign="top">A file to place at the head or tail of the
  163. concatenated text.
  164. <td valign="top" align = "center">No</td>
  165. </tr>
  166. <tr>
  167. <td valign="top">trim</td>
  168. <td valign="top">Whether to trim the value, default is "no"</td>
  169. <td valign="top" align = "center">No</td>
  170. </tr>
  171. <tr>
  172. <td valign="top">trimleading</td>
  173. <td valign="top">
  174. Whether to trim leading white space on each line, default is "no"
  175. </td>
  176. <td valign="top" align = "center">No</td>
  177. </tr>
  178. </table>
  179. <h3>Examples</h3>
  180. <p><b>Concatenate a string to a file:</b></p>
  181. <pre>
  182. &lt;concat destfile=&quot;README&quot;&gt;Hello, World!&lt;/concat&gt;
  183. </pre>
  184. <p><b>Concatenate a series of files to the console:</b></p>
  185. <pre>
  186. &lt;concat&gt;
  187. &lt;fileset dir=&quot;messages&quot; includes=&quot;*important*&quot;/&gt;
  188. &lt;/concat&gt;
  189. </pre>
  190. <p><b>Concatenate a single file, appending if the destination file exists:</b></p>
  191. <pre>
  192. &lt;concat destfile=&quot;NOTES&quot; append=&quot;true&quot;&gt;
  193. &lt;filelist dir=&quot;notes&quot; files=&quot;note.txt&quot;/&gt;
  194. &lt;/concat&gt;
  195. </pre>
  196. <p><b>Concatenate a series of files, update the destination
  197. file only if is older that all the source files:</b></p>
  198. <pre>
  199. &lt;concat destfile=&quot;${docbook.dir}/all-sections.xml&quot;
  200. force=&quot;no&quot;&gt;
  201. &lt;filelist dir=&quot;${docbook.dir}/sections&quot;
  202. files=&quot;introduction.xml,overview.xml&quot;/&gt;
  203. &lt;fileset dir=&quot;${docbook.dir}&quot;
  204. includes=&quot;sections/*.xml&quot;
  205. excludes=&quot;introduction.xml,overview.xml&quot;/&gt;
  206. &lt;/concat&gt;
  207. </pre>
  208. <p><b>Concatenate a series of files, expanding ant properties</b></p>
  209. <pre>
  210. &lt;concat destfile="${build.dir}/subs"&gt;
  211. &lt;path&gt;
  212. &lt;fileset dir="${src.dir}" includes="*.xml"/&gt;
  213. &lt;pathelement location="build.xml"/&gt;
  214. &lt;/path&gt;
  215. &lt;filterchain&gt;
  216. &lt;expandproperties/&gt;
  217. &lt;/filterchain&gt;
  218. &lt;/concat&gt;
  219. </pre>
  220. <p><b>Filter the lines containing project from build.xml and output
  221. them to report.output, prepending with a header</b></p>
  222. <pre>
  223. &lt;concat destfile="${build.dir}/report.output"&gt;
  224. &lt;header filtering="no" trimleading="yes"&gt;
  225. Lines that contain project
  226. ==========================
  227. &lt;/header&gt;
  228. &lt;path path="build.xml"/&gt;
  229. &lt;filterchain&gt;
  230. &lt;linecontains&gt;
  231. &lt;contains value="project"/&gt;
  232. &lt;/linecontains&gt;
  233. &lt;/filterchain&gt;
  234. &lt;/concat&gt;
  235. </pre>
  236. <hr>
  237. <p align="center">
  238. Copyright &copy; 2002-2004 The Apache Software Foundation. All
  239. Rights Reserved.
  240. </p>
  241. </body>
  242. </html>