public
Last active

Ant target for gzipping multiple files

  • Download Gist
gzip.xml
XML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<target name="compress">
 
<!-- store filenames in a property delimited by ; -->
<pathconvert pathsep=";" property="compress.jsfiles">
<fileset dir="${build.dir}" includes="*.js"/>
</pathconvert>
 
<script language="javascript"><![CDATA[
 
importPackage(java.io);
//get the property and convert to an array
var files = project.getProperty("compress.jsfiles").split(";"),
gzip,
i,
len;
 
for (i=0, len=files.length; i < len; i++) {
//create new gzip task
gzip = project.createTask("gzip");
gzip.setSrc(new File(files[i]));
gzip.setDestfile(new File(files[i].replace(".js", ".js.gz")));
gzip.perform();
}
 
]]> </script>
</target>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.