Copyright (c) 2001 Optiron, Inc. All Rights Reserved.
I have made some changes and enhancements to the code, but it is essentially the same as posted by Chris. Please contact him/her at the above address if you are concerned about using this code in any commercial way.
Here are the attributes to concatenate:
| Name | Default | Action |
| file | none, required | the destination file. |
| depends | true | if true, the destination is only built if the any of the source files is out of date, the beginFile or endFile is out of date, or the destination file does not exist. If false, the destination file is always rebuilt. |
| verbose | false | if true, just more logging messages are displayed. |
| fileset | none | the source files to concatenate. You can have many filesets, the union of all the files is the set of source files. See Ant's documentation about FileSets and PatternSets for more information on how to set these. |
| beginMessage | none | a string of text to prepend to the destination file. beginMessage and beginFile are mutually exclusive. |
| endMessage | none | a string of text to append to the destination file. endMessage and endFile are mutually exclusive. |
| beginFile | none | a file to prepend to the destination file. beginMessage and beginFile are mutually exclusive. |
| endFile | none | a file to append to the destination file. endMessage and endFile are mutually exclusive. |
Here is a simple target:
<!-- ==================================== -->
<target name="gen">
<concatenate file="ABuiltUpFile.html"
beginFile="preamble.txt"
endFile ="postamble.txt"
>
<fileset dir="somedir" includes="**/*.inl"/>
</concatenate>
</target>
This build.xml target creates an output file called ABuiltUpFile.html with the following contents:
The default is to build the destination file only if a source file has changed. You can override this behaviour by using depends="false":
<!-- ==================================== -->
<target name="gen">
<concatenate file="ABuiltUpFile.html"
beginFile="preamble.txt"
endFile ="postamble.txt"
depends ="false"
>
<fileset dir="somedir" includes="**/*.inl"/>
</concatenate>
</target>
The destination file is always deleted and recreated when depends="false".