/ Published in: Other

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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<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>
Comments
