source: release-kits/lirk3/resources/gs3-release-maker/ant/docs/manual/CoreTasks/concat.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

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