Compresses a Java Script file or FileSet to a new file or directory. By default, files are
compressed even if the source file is older than the destination file,
or when the destination file does not exist. However, you can explicitly
not overwrite files with the
FileSets are used to select a
set of Java Script files to compress.
To use a
must be set.
|file||The Java Script file to compress.||Yes, unless a nested
|tofile||The Java Script file to compress to.||With the
|todir||The directory to compress the file(s) to.|
|overwrite||Overwrite existing files even if the destination files are newer.||No; defaults to true.|
|flatten||Ignore the directory structure of the source files,
and compress all files into the directory specified by the
||No; defaults to false.|
|copyright||A copyright statement that will be inserted at the top of the Java Script file(s). '\n' and '\t' can be used for inserting new lines and tabs respectively.||No; defaults to no copyright statement being inserted.|
|test||If true the task will go through the compression process but will not write the compressed file to the file system. This is useful if you just want to see how much the files can be compressed by or want to syntax check the Java Script||No; defaults to false.|
|stripCR||If true the task will strip all new lines and the script will appear on one line only.||No; defaults to false.|
|failonerror||If false, log a warning message, but does not stop the build, when the file to compress does not exist or one of the nested filesets points to a directory that doesn't exist or an error occurs while compressing like the if the Java Script does not compile etc.||No; defaults to true.|
|verbose||Log the files that are being compressed and their compression ratio.||No; defaults to false.|
FileSets are used to select
sets of Java Script files to compress.
To use a fileset, the
todir attribute must be set.
<taskdef name="compress-js" classname="com.webpanes.tools.ant.taskdefs.CompressJS" classpathref="cp"/>, where 'cp' is a reference to an Ant path which has the custom_rhino.jar and compress-js.jar as path elements e.g.
<path id="cp"> <fileset dir="C:/compressjars" includes="**/*.jar"/> </path>
Compress a single Java Script file
<compress-js file="myFile.js" tofile="myCompressedFile.js"/>
Compress a single Java Script file to a directory
<compress-js file="myFile.js" todir="../some/other/dir"/>
Compress a set of Java Script files to a directory
<compress-js todir="../dest/dir"> <fileset dir="src_dir"> <include name="**/*.js"/> </fileset> </compress-js> <compress-js todir="../dest/dir" copyright="// Copyright © Webpanes.com - All rights Reserved." verbose="true" stripCR="true"> <fileset dir="src_dir" includes="**/*.js"/> </compress-js>
Copyright © LCA Soft Limited. All rights Reserved.