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