Skip to content

Instantly share code, notes, and snippets.

@nzakas
Created December 23, 2011 15:51
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nzakas/1514525 to your computer and use it in GitHub Desktop.
Save nzakas/1514525 to your computer and use it in GitHub Desktop.
Ant target for gzipping multiple files
<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>
@greenkiwi
Copy link

Thank you very much. This was extremely helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment