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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  5. <title>Concat</title>
  6. </head>
  7. <body>
  8. <h2><a name="Concat">Concat</a></h2>
  9. <h3>Description</h3>
  10. <p>
  11. Concatenates one or more
  12. <a href="../CoreTypes/resources.html">resource</a>s
  13. to a single file or to the console. The destination
  14. file will be created if it does not exist.
  15. </p>
  16. <p>
  17. <a href="../CoreTypes/resources.html#collection">
  18. Resource Collection</a>s are used to
  19. select which resources are to be concatenated. There is no
  20. singular attribute to specify a single resource to cat.
  21. </p>
  22. <h3>Parameters</h3>
  23. <table border="1" cellpadding="2" cellspacing="0">
  24. <tr>
  25. <td valign="top"><b>Attribute</b></td>
  26. <td valign="top"><b>Description</b></td>
  27. <td align="center" valign="top"><b>Required</b></td>
  28. </tr>
  29. <tr>
  30. <td valign="top">destfile</td>
  31. <td valign="top">
  32. The destination file for the concatenated stream.
  33. If not specified the console will be used instead.
  34. </td>
  35. <td valign="top" align="center">
  36. No
  37. </td>
  38. </tr>
  39. <tr>
  40. <td valign="top">append</td>
  41. <td valign="top">
  42. Specifies whether or not the file specified by 'destfile'
  43. should be appended. Defaults to &quot;no&quot;.
  44. </td>
  45. <td valign="top" align="center">No</td>
  46. </tr>
  47. <tr>
  48. <td valign="top">force</td>
  49. <td valign="top">
  50. Specifies whether or not the file specified by 'destfile'
  51. should be written to even if it is newer than all source files.
  52. <em>since Ant 1.6</em>.
  53. Defaults to &quot;yes&quot;.
  54. </td>
  55. <td valign="top" align="center">No</td>
  56. </tr>
  57. <tr>
  58. <td valign="top">encoding</td>
  59. <td valign="top">
  60. Specifies the encoding for the input files. Please see <a
  61. href="http://java.sun.com/products/jdk/1.2/docs/guide/internat/encoding.doc.html">
  62. http://java.sun.com/products/jdk/1.2/docs/guide/internat/encoding.doc.html</a>
  63. for a list of possible values. Defaults to the platform's
  64. default character encoding.
  65. </td>
  66. <td valign="top" align="center">No</td>
  67. </tr>
  68. <tr>
  69. <td valign="top">outputencoding</td>
  70. <td valign="top">
  71. The encoding to use when writing the output file
  72. <em>since Ant 1.6</em>.
  73. Defaults to the value of the encoding attribute
  74. if given or the default JVM encoding otherwise.
  75. </td>
  76. <td valign="top" align="center">No</td>
  77. </tr>
  78. <tr>
  79. <td valign="top">fixlastline</td>
  80. <td valign="top">
  81. Specifies whether or not to check if
  82. each file concatenated is terminated by
  83. a new line. If this attribute is &quot;yes&quot;
  84. a new line will be appended to the stream if
  85. the file did not end in a new line.
  86. <em>since Ant 1.6</em>.
  87. Defaults to &quot;no&quot;.
  88. This attribute does not apply to embedded text.
  89. </td>
  90. <td valign="top" align="center">No</td>
  91. </tr>
  92. <tr>
  93. <td valign="top">eol</td>
  94. <td valign="top">
  95. Specifies what the end of line character are
  96. for use by the fixlastline attribute.
  97. <em>since Ant 1.6</em>
  98. Valid values for this property are:
  99. <ul>
  100. <li>cr: a single CR</li>
  101. <li>lf: a single LF</li>
  102. <li>crlf: the pair CRLF</li>
  103. <li>mac: a single CR</li>
  104. <li>unix: a single LF</li>
  105. <li>dos: the pair CRLF</li>
  106. </ul>
  107. The default is platform dependent.
  108. For Unix platforms, the default is &quot;lf&quot;.
  109. For DOS based systems (including Windows),
  110. the default is &quot;crlf&quot;.
  111. For Mac OS, the default is &quot;cr&quot;.
  112. </td>
  113. <td valign="top" align="center">No</td>
  114. </tr>
  115. <tr>
  116. <td valign="top">binary</td>
  117. <td valign="top">
  118. <em>since Ant 1.6.2</em>
  119. If this attribute is set to true, the task concatenates the files
  120. in a byte by byte fashion. If this attribute is false, concat will
  121. not normally work for binary files due to character encoding
  122. issues.
  123. If this option is set to true, the destfile attribute must be
  124. set, and the task cannot used nested text.
  125. Also the attributes encoding, outputencoding, filelastline
  126. cannot be used.
  127. The default is false.
  128. </td>
  129. <td valign="top" align="center">No</td>
  130. </tr>
  131. </table>
  132. <h3>Parameters specified as nested elements</h3>
  133. <h4>Resource Collection</h4>
  134. <p><em>since Ant 1.7</em>.</p>
  135. <p>
  136. Any of the various <a href="../CoreTypes/resources.html#collection">
  137. Resource Collection</a> types can specify the resources to be
  138. concatenated.
  139. </p>
  140. <h4>filterchain</h4>
  141. <p><em>since Ant 1.6</em>.</p>
  142. <p>The concat task supports nested
  143. <a href="../CoreTypes/filterchain.html"> FilterChain</a>s.</p>
  144. <h4>header, footer</h4>
  145. <p><em>since Ant 1.6</em>.</p>
  146. <p>Used to prepend or postpend text into the concatenated stream.</p>
  147. <p>The text may be in-line or be in a file.</p>
  148. <table border="1" cellpadding="2" cellspacing="0">
  149. <tr>
  150. <td valign="top"><b>Attribute</b></td>
  151. <td valign="top"><b>Description</b></td>
  152. <td align="center" valign="top"><b>Required</b></td>
  153. </tr>
  154. <tr>
  155. <td valign="top">filtering</td>
  156. <td valign="top">
  157. Whether to filter the text provided by this sub element,
  158. default is "yes".
  159. <td valign="top" align = "center">No</td>
  160. </tr>
  161. <tr>
  162. <td valign="top">file</td>
  163. <td valign="top">A file to place at the head or tail of the
  164. concatenated text.
  165. <td valign="top" align = "center">No</td>
  166. </tr>
  167. <tr>
  168. <td valign="top">trim</td>
  169. <td valign="top">Whether to trim the value, default is "no"</td>
  170. <td valign="top" align = "center">No</td>
  171. </tr>
  172. <tr>
  173. <td valign="top">trimleading</td>
  174. <td valign="top">
  175. Whether to trim leading white space on each line, default is "no"
  176. </td>
  177. <td valign="top" align = "center">No</td>
  178. </tr>
  179. </table>
  180. <h3>Examples</h3>
  181. <p><b>Concatenate a string to a file:</b></p>
  182. <pre>
  183. &lt;concat destfile=&quot;README&quot;&gt;Hello, World!&lt;/concat&gt;
  184. </pre>
  185. <p><b>Concatenate a series of files to the console:</b></p>
  186. <pre>
  187. &lt;concat&gt;
  188. &lt;fileset dir=&quot;messages&quot; includes=&quot;*important*&quot;/&gt;
  189. &lt;/concat&gt;
  190. </pre>
  191. <p><b>Concatenate a single file, appending if the destination file exists:</b></p>
  192. <pre>
  193. &lt;concat destfile=&quot;NOTES&quot; append=&quot;true&quot;&gt;
  194. &lt;filelist dir=&quot;notes&quot; files=&quot;note.txt&quot;/&gt;
  195. &lt;/concat&gt;
  196. </pre>
  197. <p><b>Concatenate a series of files, update the destination
  198. file only if is older that all the source files:</b></p>
  199. <pre>
  200. &lt;concat destfile=&quot;${docbook.dir}/all-sections.xml&quot;
  201. force=&quot;no&quot;&gt;
  202. &lt;filelist dir=&quot;${docbook.dir}/sections&quot;
  203. files=&quot;introduction.xml,overview.xml&quot;/&gt;
  204. &lt;fileset dir=&quot;${docbook.dir}&quot;
  205. includes=&quot;sections/*.xml&quot;
  206. excludes=&quot;introduction.xml,overview.xml&quot;/&gt;
  207. &lt;/concat&gt;
  208. </pre>
  209. <p><b>Concatenate a series of files, expanding ant properties</b></p>
  210. <pre>
  211. &lt;concat destfile="${build.dir}/subs"&gt;
  212. &lt;path&gt;
  213. &lt;fileset dir="${src.dir}" includes="*.xml"/&gt;
  214. &lt;pathelement location="build.xml"/&gt;
  215. &lt;/path&gt;
  216. &lt;filterchain&gt;
  217. &lt;expandproperties/&gt;
  218. &lt;/filterchain&gt;
  219. &lt;/concat&gt;
  220. </pre>
  221. <p><b>Filter the lines containing project from build.xml and output
  222. them to report.output, prepending with a header</b></p>
  223. <pre>
  224. &lt;concat destfile="${build.dir}/report.output"&gt;
  225. &lt;header filtering="no" trimleading="yes"&gt;
  226. Lines that contain project
  227. ==========================
  228. &lt;/header&gt;
  229. &lt;path path="build.xml"/&gt;
  230. &lt;filterchain&gt;
  231. &lt;linecontains&gt;
  232. &lt;contains value="project"/&gt;
  233. &lt;/linecontains&gt;
  234. &lt;/filterchain&gt;
  235. &lt;/concat&gt;
  236. </pre>
  237. <p><b>Concatenate a number of binary files.</b></p>
  238. <pre>
  239. &lt;concat destfile="${build.dir}/dist.bin" binary="yes"&gt;
  240. &lt;fileset file="${src.dir}/scripts/dist.sh"&gt;
  241. &lt;fileset file="${build.dir}/dist.tar.bz2"&gt;
  242. &lt;/concat&gt;
  243. </pre>
  244. <hr>
  245. <p align="center">
  246. Copyright &copy; 2002-2005 The Apache Software Foundation. All
  247. Rights Reserved.
  248. </p>
  249. </body>
  250. </html>