~ubuntu-branches/ubuntu/trusty/ant/trusty

« back to all changes in this revision

Viewing changes to docs/manual/Tasks/concat.html

  • Committer: Bazaar Package Importer
  • Author(s): James Page, James Page, Niels Thykier
  • Date: 2011-05-04 15:16:42 UTC
  • mfrom: (5.2.8 sid)
  • Revision ID: james.westby@ubuntu.com-20110504151642-3cm7tbh8rwkdbpx8
[ James Page ]
* New upstream release (Closes: #613914).
  - Fix FTBFS for jug with ant 1.8.1 (Closes: #610320).
* Bumped Standards-Version to 3.9.2, no changes.
* Removed ant-nodeps.jar from install as now part of ant core. 
* Added myself to Uploaders.

[ Niels Thykier ]
* Added missing mh_clean, thanks to Miguel Landaeta for spotting
  this.
* Fixed a typo in the ant manpage.
* Made short descriptions unique.
* Bumped debhelper compat to 7.
* Removed empty linda-override dir from ant-doc.
* Removed redundant Priority fields in d/control.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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="../Types/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 unless the resource
 
36
        list is empty and ignoreempty is true.
 
37
      </p>
 
38
 
 
39
      <p><strong>Since Apache Ant 1.7.1</strong>, this task can be used as a
 
40
        <a href="../Types/resources.html#collection">Resource Collection</a>
 
41
        that will return exactly one 
 
42
        <a href="../Types/resources.html">resource</a>.
 
43
      </p>
 
44
 
 
45
      <p>
 
46
        <a href="../Types/resources.html#collection">
 
47
Resource Collection</a>s are used to
 
48
        select which resources are to be concatenated. There is no
 
49
        singular attribute to specify a single resource to cat.
 
50
      </p>
 
51
 
 
52
      <h3>Parameters</h3>
 
53
 
 
54
      <table border="1" cellpadding="2" cellspacing="0">
 
55
 
 
56
        <tr>
 
57
          <td valign="top"><b>Attribute</b></td>
 
58
          <td valign="top"><b>Description</b></td>
 
59
          <td align="center" valign="top"><b>Required</b></td>
 
60
        </tr>
 
61
 
 
62
        <tr>
 
63
          <td valign="top">destfile</td>
 
64
          <td valign="top">
 
65
            The destination file for the concatenated stream.
 
66
        If not specified the console will be used instead.
 
67
          </td>
 
68
          <td valign="top" align="center">
 
69
            No
 
70
          </td>
 
71
        </tr>
 
72
 
 
73
        <tr>
 
74
          <td valign="top">append</td>
 
75
          <td valign="top">
 
76
            Specifies whether or not the file specified by 'destfile'
 
77
            should be appended. Defaults to &quot;no&quot;.
 
78
          </td>
 
79
          <td valign="top" align="center">No</td>
 
80
        </tr>
 
81
        <tr>
 
82
          <td valign="top">force</td>
 
83
          <td valign="top">
 
84
            Specifies whether or not the file specified by 'destfile'
 
85
            should be written to even if it is newer than all source files.
 
86
            <strong>deprecated, use the overwrite attribute instead</strong>
 
87
            Defaults to &quot;yes&quot;.
 
88
          </td>
 
89
          <td valign="top" align="center">No</td>
 
90
        </tr>
 
91
        <tr>
 
92
          <td valign="top">overwrite</td>
 
93
          <td valign="top">
 
94
            Specifies whether or not the file specified by 'destfile'
 
95
            should be written to even if it is newer than all source files.
 
96
            <em>since Ant 1.8.2</em>.
 
97
            Defaults to &quot;yes&quot;.
 
98
          </td>
 
99
          <td valign="top" align="center">No</td>
 
100
        </tr>
 
101
 
 
102
        <tr>
 
103
          <td valign="top">forceReadOnly</td>
 
104
          <td valign="top">Overwrite read-only destination
 
105
            files.  <em>since Ant 1.8.2</em></td>
 
106
          <td valign="top" align="center">No; defaults to false.</td>
 
107
        </tr>
 
108
 
 
109
        <tr>
 
110
          <td valign="top">encoding</td>
 
111
          <td valign="top">
 
112
            Specifies the encoding for the input files. Please see <a
 
113
            href="http://download.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html">
 
114
            http://download.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html</a>
 
115
            for a list of possible values. Defaults to the platform's
 
116
            default character encoding.
 
117
          </td>
 
118
          <td valign="top" align="center">No</td>
 
119
        </tr>
 
120
        <tr>
 
121
          <td valign="top">outputencoding</td>
 
122
          <td valign="top">
 
123
            The encoding to use when writing the output file
 
124
            <em>since Ant 1.6</em>.
 
125
            Defaults to the value of the encoding attribute
 
126
            if given or the default JVM encoding otherwise.
 
127
          </td>
 
128
          <td valign="top" align="center">No</td>
 
129
        </tr>
 
130
        <tr>
 
131
          <td valign="top">fixlastline</td>
 
132
          <td valign="top">
 
133
                 Specifies whether or not to check if
 
134
            each file concatenated is terminated by
 
135
            a new line. If this attribute is &quot;yes&quot;
 
136
            a new line will be appended to the stream if
 
137
            the file did not end in a new line.
 
138
            <em>since Ant 1.6</em>.
 
139
            Defaults to &quot;no&quot;.
 
140
            This attribute does not apply to embedded text.
 
141
          </td>
 
142
          <td valign="top" align="center">No</td>
 
143
        </tr>
 
144
        <tr>
 
145
          <td valign="top">eol</td>
 
146
          <td valign="top">
 
147
            Specifies what the end of line character are
 
148
            for use by the fixlastline attribute.
 
149
            <em>since Ant 1.6</em>
 
150
            Valid values for this property are:
 
151
            <ul>
 
152
              <li>cr: a single CR</li>
 
153
              <li>lf: a single LF</li>
 
154
              <li>crlf: the pair CRLF</li>
 
155
              <li>mac: a single CR</li>
 
156
              <li>unix: a single LF</li>
 
157
              <li>dos: the pair CRLF</li>
 
158
            </ul>
 
159
            The default is platform dependent.
 
160
            For Unix platforms, the default is &quot;lf&quot;.
 
161
            For DOS based systems (including Windows),
 
162
            the default is &quot;crlf&quot;.
 
163
            For Mac OS, the default is &quot;cr&quot;.
 
164
          </td>
 
165
          <td valign="top" align="center">No</td>
 
166
        </tr>
 
167
        <tr>
 
168
          <td valign="top">binary</td>
 
169
          <td valign="top">
 
170
            <em>since Ant 1.6.2</em>
 
171
            If this attribute is set to true, the task concatenates the files
 
172
            in a byte by byte fashion. If this attribute is false, concat will
 
173
            not normally work for binary files due to character encoding
 
174
            issues.
 
175
            If this option is set to true, the destfile attribute must be
 
176
            set, and the task cannot used nested text.
 
177
            Also the attributes encoding, outputencoding, filelastline
 
178
            cannot be used.
 
179
            The default is &quot;false&quot;.
 
180
          </td>
 
181
          <td valign="top" align="center">No</td>
 
182
        </tr>
 
183
        <tr>
 
184
          <td valign="top">ignoreempty</td>
 
185
          <td valign="top">
 
186
          <em>Since Ant 1.8.0</em>
 
187
            Specifies whether or not the file specified by 'destfile'
 
188
            should be created if the source resource list is
 
189
            empty. Defaults to &quot;true&quot;.
 
190
          </td>
 
191
          <td valign="top" align="center">No</td>
 
192
        </tr>
 
193
 
 
194
      </table>
 
195
 
 
196
      <h3>Parameters specified as nested elements</h3>
 
197
        <h4>Resource Collection</h4>
 
198
        <p><em>since Ant 1.7</em>.</p>
 
199
 
 
200
      <p>
 
201
        Any of the various <a href="../Types/resources.html#collection">
 
202
        Resource Collection</a> types can specify the resources to be
 
203
        concatenated.
 
204
      </p>
 
205
 
 
206
      <h4>filterchain</h4>
 
207
        <p><em>since Ant 1.6</em>.</p>
 
208
      <p>The concat task supports nested
 
209
        <a href="../Types/filterchain.html"> FilterChain</a>s.</p>
 
210
 
 
211
      <h4>header, footer</h4>
 
212
        <p><em>since Ant 1.6</em>.</p>
 
213
      <p>Used to prepend or postpend text into the concatenated stream.</p>
 
214
      <p>The text may be in-line or be in a file.</p>
 
215
      <table border="1" cellpadding="2" cellspacing="0">
 
216
        <tr>
 
217
          <td valign="top"><b>Attribute</b></td>
 
218
          <td valign="top"><b>Description</b></td>
 
219
          <td align="center" valign="top"><b>Required</b></td>
 
220
        </tr>
 
221
        <tr>
 
222
          <td valign="top">filtering</td>
 
223
          <td valign="top">
 
224
            Whether to filter the text provided by this sub element,
 
225
            default is "yes".
 
226
          <td valign="top" align = "center">No</td>
 
227
        </tr>
 
228
        <tr>
 
229
          <td valign="top">file</td>
 
230
          <td valign="top">A file to place at the head or tail of the
 
231
                           concatenated text.
 
232
          <td valign="top" align = "center">No</td>
 
233
        </tr>
 
234
        <tr>
 
235
          <td valign="top">trim</td>
 
236
          <td valign="top">Whether to trim the value, default is "no"</td>
 
237
          <td valign="top" align = "center">No</td>
 
238
        </tr>
 
239
        <tr>
 
240
          <td valign="top">trimleading</td>
 
241
          <td valign="top">
 
242
            Whether to trim leading white space on each line, default is "no"
 
243
          </td>
 
244
          <td valign="top" align = "center">No</td>
 
245
        </tr>
 
246
      </table>
 
247
 
 
248
      <h3>Examples</h3>
 
249
 
 
250
      <p><b>Concatenate a string to a file:</b></p>
 
251
 
 
252
      <pre>
 
253
  &lt;concat destfile=&quot;README&quot;&gt;Hello, World!&lt;/concat&gt;
 
254
      </pre>
 
255
 
 
256
      <p><b>Concatenate a series of files to the console:</b></p>
 
257
 
 
258
      <pre>
 
259
  &lt;concat&gt;
 
260
    &lt;fileset dir=&quot;messages&quot; includes=&quot;*important*&quot;/&gt;
 
261
  &lt;/concat&gt;
 
262
      </pre>
 
263
 
 
264
      <p><b>Concatenate a single file, appending if the destination file exists:</b></p>
 
265
 
 
266
      <pre>
 
267
  &lt;concat destfile=&quot;NOTES&quot; append=&quot;true&quot;&gt;
 
268
    &lt;filelist dir=&quot;notes&quot; files=&quot;note.txt&quot;/&gt;
 
269
  &lt;/concat&gt;
 
270
      </pre>
 
271
 
 
272
      <p><b>Concatenate a series of files, update the destination
 
273
      file only if is older that all the source files:</b></p>
 
274
 
 
275
      <pre>
 
276
  &lt;concat destfile=&quot;${docbook.dir}/all-sections.xml&quot;
 
277
          force=&quot;no&quot;&gt;
 
278
    &lt;filelist dir=&quot;${docbook.dir}/sections&quot;
 
279
         files=&quot;introduction.xml,overview.xml&quot;/&gt;
 
280
    &lt;fileset dir=&quot;${docbook.dir}&quot;
 
281
         includes=&quot;sections/*.xml&quot;
 
282
         excludes=&quot;introduction.xml,overview.xml&quot;/&gt;
 
283
  &lt;/concat&gt;
 
284
      </pre>
 
285
 
 
286
      <p><b>Concatenate a series of files, expanding ant properties</b></p>
 
287
        <pre>
 
288
   &lt;concat destfile="${build.dir}/subs"&gt;
 
289
      &lt;path&gt;
 
290
        &lt;fileset dir="${src.dir}" includes="*.xml"/&gt;
 
291
        &lt;pathelement location="build.xml"/&gt;
 
292
      &lt;/path&gt;
 
293
      &lt;filterchain&gt;
 
294
        &lt;expandproperties/&gt;
 
295
      &lt;/filterchain&gt;
 
296
   &lt;/concat&gt;
 
297
        </pre>
 
298
 
 
299
      <p><b>Filter the lines containing project from build.xml and output
 
300
           them to report.output, prepending with a header</b></p>
 
301
        <pre>
 
302
   &lt;concat destfile="${build.dir}/report.output"&gt;
 
303
      &lt;header filtering="no" trimleading="yes"&gt;
 
304
          Lines that contain project
 
305
          ==========================
 
306
      &lt;/header&gt;
 
307
      &lt;path path="build.xml"/&gt;
 
308
      &lt;filterchain&gt;
 
309
         &lt;linecontains&gt;
 
310
           &lt;contains value="project"/&gt;
 
311
         &lt;/linecontains&gt;
 
312
      &lt;/filterchain&gt;
 
313
   &lt;/concat&gt;
 
314
        </pre>
 
315
 
 
316
      <p><b>Concatenate a number of binary files.</b></p>
 
317
        <pre>
 
318
   &lt;concat destfile="${build.dir}/dist.bin" binary="yes"&gt;
 
319
     &lt;fileset file="${src.dir}/scripts/dist.sh" /&gt;
 
320
     &lt;fileset file="${build.dir}/dist.tar.bz2" /&gt;
 
321
   &lt;/concat&gt;
 
322
        </pre>
 
323
 
 
324
      
 
325
 
 
326
    </body>
 
327
 
 
328
  </html>