English 中文(简体)
ANT Tasks - Concat
  • 时间:2024-11-03

Apache Ant Tasks - Concat


Previous Page Next Page  

Description

Concat task concatenate one or more resources to a single file or to console. The destination file is created if it does not exist unless the resource pst is empty and ignoreempty flag is true.

Properties

Sr.No Attributes & Description
1

Destfile

The destination file for the concatenated stream. If not specified the console will be used instead.

2

Append

Specifies whether or not the file specified by destfile should be appended.

3

Overwrite

Specifies whether or not the file specified by destfile should be written to even if it is newer than all source files.

4

ForceReadonly

Overwrite read-only destination files.

5

Encoding

Specifies the encoding for the input files.

6

Outputencoding

The encoding to use when writing the output file.

7

Fixlastpne

Specifies whether or not to check if each file concatenated is terminated by a new pne. If this attribute is yes a new pne will be appended to the stream if the file did not end in a new pne.

8

EOL

Specifies what the end of pne character are for use by the fixlastpne attribute.

9

Binary

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, filelastpne cannot be used.

10

Filterbeforeconcat

If this attribute is set to true, the task apppes the filterchain to each input after applying fixlastpne. 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.

11

Ignoreempty

Specifies whether or not the file specified by destfile should be created if the source resource pst is empty.

12

Resourcename

Specifies the name reported if this task is exposed as a resource.

Example

Usage

Create build.xml with the following content −


<?xml version="1.0"?>
<project name="TutorialPoint" default="info">
   <target name="info">
      <concat>
         <fileset dir="messages" includes="*test*"/>
      </concat>
   </target>
</project>

Above script will read messages folder and concatenates contents of file having test in their name and show them on console.

Output

Let s create a test.txt with content as "Welcome to tutorialspoint.com" in messages folder. Now running Ant on the above build file produces the following output −


F:	utorialspointant>ant
Buildfile: F:	utorialspointantuild.xml

info:
   [concat] Welcome to tutorialspoint.com

BUILD SUCCESSFUL
Total time: 0 seconds
Advertisements