Return to Snippet

Revision: 30064
at August 6, 2010 21:16 by gotofritz


Initial Code
<property
	name	= "dir.from"
	value	= "/PATH/TO/SOURCE/DIRECTORY/"
	/>
<property
	name	= "dir.to"
	value	= "/PATH/TO/TARGET/DIRECTORY/"
	/>


<target
	name	= "collateJS"
	description	= "collects JS files"
	>
	<!-- creates a timestamp - useful when someone reads the file without access to ant -->
	<tstamp>
		<format
			property		= "generated"
			pattern		= "yyyy-MM-dd HH:mm:ss"
			locale		= "en,UK"
			/>
	 </tstamp>

	<!-- clears file and puts a JS style comment on top -->
	<concat
		destfile		= "${dir.to}/concat.js"
		append		= "false"><![CDATA[//generated by ant task collateJS ${generated}

 ]]></concat>

	<!-- does the concatenating -->
	<concat
		destfile		= "${dir.to}/concat.js"
		append		= "true">
		
			<!-- list individual files manually -->
			<filelist 
			    dir	= "${dir.from}"
				>
				<file name="file1.js" />
				<file name="file2.js" />
			</filelist>
		
			<!-- creates a filter -->
			<fileset
				dir	= "${dir.from}"
				>
				<include name="**/yes*"/>
				<exclude name="**/no*"/>
			</fileset>
		</concat>
</target>

Initial URL


Initial Description
Simple file concatenation target using the concat task. The to and from directories are set in properties at the top. The first concat clears the file and writes a JS comment with the date on it, the second uses both a filelist (where you write filenames manually) and a fileset (where you just write a filter) to select the files to include.

Initial Title
ANT: Collate files

Initial Tags
file

Initial Language
Other