B.3 AppendTask

The Append Task appends text or contents of files to a specified file.

In the example above, AppendTask is reading a filename from book/PhingGuide.book, processing the file contents with XSLT, and then appending the result to the file located at ${process.outputfile}. This is a real example from the build file used to generate this book!

Note

By default, whitespace is stripped from text that is appended to a file (matching the way the Concat task works in Ant). This is because adding a nested text element may introduce additional (ignorable) whitespace. If you want to override this behavior, set the skipsanitize attribute to true.

Table B.3: Attributes

NameTypeDescriptionDefaultRequired
destFile File Path of file to which text should be appended. If not specified the console will be used instead. n/aNo
append String Specifies whether or not the file specified by 'destfile' should be appended. Defaults to "yes". yesNo
overwrite Boolean Specifies whether or not the file specified by 'destfile' should be written to even if it is newer than all source files. yesNo
fixlastline Boolean Specifies whether or not to check if each file concatenated is terminated by a new line. If this attribute is "yes" a new line will be appended to the stream if the file did not end in a new line. This attribute does not apply to embedded text. noNo
eol String Specifies what the end of line character are for use by the fixlastline attribute. Valid values for this property are:
  • cr: a single CR

  • lf: a single LF

  • crlf: the pair CRLF

  • mac: a single CR

  • unix: a single LF

  • dos: the pair CRLF

The default is platform dependent. For Unix platforms, the default is "lf". For DOS based systems (including Windows), the default is "crlf". For Mac OS, the default is "cr".
n/aNo
skipsanitize Boolean Specifies whether to skip sanitizing text (i.e., stripping spaces and newlines). n/aNo
file File Path to file that should be appended to destFile.n/aNo
text String Some literal text to append to file.n/aNo

B.3.1 Examples

<append destFile="${process.outputfile}">
        <filterchain>
            <xsltfilter style="${process.stylesheet}">
                <param name="mode" expression="${process.xslt.mode}"/>
            </xsltfilter>
        </filterchain>
    <filelist dir="book/" listfile="book/PhingGuide.book"/>
</append>
        

B.3.2 Supported Nested Tags

  • filelist

  • fileset

  • filterchain

  • path

  • header, footer Used to prepend or postpend text into the concatenated stream. The text may be in-line or be in a file.

    Table B.4: Attributes

    NameTypeDescriptionDefaultRequired
    filtering Boolean Whether to filter the text provided by this sub element.yesNo
    file String A file to place at the head or tail of the concatenated text.n/aNo
    trim Boolean Whether to trim the value.noNo
    trimleading Boolean Whether to trim leading white space on each line.noNo