concatenate : concatenates multiple files into one destination.

Download Files

Changes

  1. Initial Version

Installation

  1. You must have netcomponents.jar in the the ant\lib directory.
  2. copy jarrizza.jar into directory ant\lib
  3. add the following line to your build.xml
  4. <taskdef name="concatenate" classname="com.arrizza.ant.taskdefs.ConcatenateFiles"/>
  5. or add the line from the defaults.properties file and recompile ant

Notes

This is a new Taskdef for Ant. It concatenates multiple source files into one destination file.

Copyright

This file originated from a posting on an Ant mailing list by a person named Chris Winters (cwinters@optiron.com). It's copyright is held by
      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.

Use

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.

Samples

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:

  1. preamble.txt
  2. any *.inl files in directory somedir
  3. postamble.txt

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".




Contact me about content on this page using john_web-at-arrizza-dot-com
For Web Master or site problems contact: webadmin-at-arrizza-dot-com
Copyright John Arrizza (c) 2001,2002,2003,2004,2005,2006,2007