Concatenates one or more resources to a single file or
to the console. The destination file will be created if it does not exist unless the resource
list is empty and ignoreempty is true
.
Since Apache Ant 1.7.1, this task can be used as a resource collection that will return exactly one resource.
Resource collections are used to select
which resources are to be concatenated. There is no singular attribute to specify a single
resource to concat
.
Attribute | Description | Required |
---|---|---|
destfile | The destination file for the concatenated stream. If not specified the console will be used instead. | No |
append | Specifies whether or not the file specified by destfile should be appended. | No; defaults to no |
force | Specifies whether or not the file specified by destfile should be written to even if it is newer than all source files. Deprecated, use the overwrite attribute instead. | No; defaults to yes |
overwrite | Specifies whether or not the file specified by destfile should be written to even if it is newer than all source files. Since Ant 1.8.2. | No; defaults to yes |
forceReadOnly | Overwrite read-only destination files. Since Ant 1.8.2 | No; defaults to false |
encoding | Specifies the encoding for the input files. Please see Supported Encodings for a list of possible values. | No; defaults to default JVM character encoding |
outputencoding | The encoding to use when writing the output file. Since Ant 1.6. | No; defaults to encoding if set or default JVM character encoding otherwise |
fixlastline | Specifies whether or not to check if each file concatenated is terminated by a new
line. If this attribute is yesa new line will be appended to the stream if the file did not end in a new line. Since Ant 1.6. This attribute does not apply to embedded text. |
No; defaults to no |
eol | Specifies what the end of line character are for use by the fixlastline
attribute. Since Ant 1.6 Valid values for this property are:
|
No; default is platform dependent: lffor Unix, crlffor DOS family (including Windows), crfor Mac OS 9 or earlier |
binary | Since Ant 1.6.2 If this attribute is set to true, the task concatenates the files in a byte by byte fashion. If this attribute is false, concat will not normally work for binary files due to character encoding issues. If this option is set to true, the destfile attribute must be set, and the task cannot used nested text. Also the attributes encoding, outputencoding, filelastline cannot be used. |
No; default is false |
filterbeforeconcat | If this attribute is set to true, the task applies the filterchain to each input after applying fixlastline . If this attribute is false, concat will apply the filterchain only once to the already concatenated inputs. Filtering of header and footer is not affected by this setting.
Since Ant 1.10.10 |
No; default is false |
ignoreempty | Since Ant 1.8.0 Specifies whether or not the file specified by destfile should be created if the source resource list is empty. | No; defaults to true |
resourcename | Since Ant 1.8.3 Specifies the name reported if this task is exposed as a resource. | No |
Since Ant 1.7.
Any of the various resource collection types can specify the resources to be concatenated.
Since Ant 1.6.
The task supports nested FilterChains.
Since Ant 1.6.
Used to prepend or postpend text into the concatenated stream.
The text may be in-line or be in a file.
Attribute | Description | Required |
---|---|---|
filtering | Whether to filter the text provided by this sub element. | No; default is yes |
file | A file to place at the head or tail of the concatenated text. | No |
trim | Whether to trim the value. | No; default is no |
trimleading | Whether to trim leading white space on each line. | No; default is no |
Concatenate a string to a file:
<concat destfile="README">Hello, World!</concat>
Concatenate a series of files to the console:
<concat> <fileset dir="messages" includes="*important*"/> </concat>
Concatenate a single file, appending if the destination file exists:
<concat destfile="NOTES" append="true"> <filelist dir="notes" files="note.txt"/> </concat>
Concatenate a series of files, update the destination file only if is older that all the source files:
<concat destfile="${docbook.dir}/all-sections.xml" force="no"> <filelist dir="${docbook.dir}/sections" files="introduction.xml,overview.xml"/> <fileset dir="${docbook.dir}" includes="sections/*.xml" excludes="introduction.xml,overview.xml"/> </concat>
Concatenate a series of files, expanding Ant properties.
<concat destfile="${build.dir}/subs"> <path> <fileset dir="${src.dir}" includes="*.xml"/> <pathelement location="build.xml"/> </path> <filterchain> <expandproperties/> </filterchain> </concat>
Filter the lines containing project from build.xml and output them to report.output, prepending with a header.
<concat destfile="${build.dir}/report.output"> <header filtering="no" trimleading="yes"> Lines that contain project ========================== </header> <path path="build.xml"/> <filterchain> <linecontains> <contains value="project"/> </linecontains> </filterchain> </concat>
Concatenate a number of binary files.
<concat destfile="${build.dir}/dist.bin" binary="yes"> <fileset file="${src.dir}/scripts/dist.sh"/> <fileset file="${build.dir}/dist.tar.bz2"/> </concat>