For each of the supported compression formats there is a correspondig task that compresses a resource. These tasks are not based on their core cousin tasks but provide similar functionality.
Attribute | Description | Required |
src | the resource to compress. | Yes, or a nested resource collection or a nested archiving task. |
srcfile | the file to compress. | |
dest | the destination resource to create. | Exactly one of the two or a nested dest element. |
destfile | the destination file to create. |
The specified resource will be used as src.
The task's output will be used as src.
You must not specify the archiving task's dest attribute or nested element.
Since Compress Antlib 1.1
The task's output will be used as src.
You must not specify the compressing task's dest attribute or nested element.
Accepts any resource or single element resource collection as nested element.
The specified resource will be used as dest.
Is a compressing task that uses the BZIP2 compression algorithm.
Is a compressing task that uses the GZIP compression algorithm.
This task supports the following additional attributes:
Attribute | Description | Required |
level | Non-default level at which file compression should be performed. Valid values range from 0 (no compression/fastest) to 9 (maximum compression/slowest). Since Compress Antlib 1.5 | No |
Is a compressing task that uses the Pack200 compression algorithm.
The source of this task must be a valid JAR archive.
The created archive will not be compressed, use
another <gzip>
task to create
a pack.gz
archive.
In addition to the attributes supported by all compressing task this task also supports.
Attribute | Description | Required |
pack200strategy | Apache Commons Compress' Pack200 streams cache the archive data either in memory or in a temporary file. User this attribute to control which strategy is chosen. Valid values are "in-memory" and "temp-file". | No, defaults to in-memory. |
In addition to the nested elements supported by all compressing task this task also supports.
Sets a property for the packer (see the Pack200 javadocs for details).
Attribute | Description | Required |
key | Name of the property. | Yes. |
value | Value of the property. | Yes. |
Is a compressing task that uses the XZ compression algorithm.
<cmp:gzip src="test.tar" dest="test.tar.gz" xmlns:cmp="antlib:org.apache.ant.compress"/>
<cmp:bzip2 src="test.tar" destfile="test.tar.bz2" xmlns:cmp="antlib:org.apache.ant.compress"/>
<cmp:gzip destfile="archive.tar.gz" xmlns:cmp="antlib:org.apache.ant.compress"> <url url="http://example.org/archive.tar"/> </cmp:gzip>
downloads http://example.org/archive.tar and compresses it to archive.tar.gz in the project's basedir on the fly.
<cmp:gzip xmlns:cmp="antlib:org.apache.ant.compress"> <cmp:tar> <fileset dir="src"/> </cmp:tar> <dest> <file file="src.tar.gz"/> </dest> </cmp:gzip>
Creates a tar archive of all files in the src directory, compresses it using GZIP and stores it in the file src.tar.gz in the project's basedir.
<cmp:pack200 dest="foo.pack" xmlns:cmp="antlib:org.apache.ant.compress" src="foo.jar"> <property key="pack.effort" value="9"/> </cmp:pack200>
Packs foo.jar trying to prepare for better compression results by using above than normal effort.
<cmp:gzip xmlns:cmp="antlib:org.apache.ant.compress"> <cmp:pack200> <file file="foo.jar"/> </cmp:pack200> <dest> <file file="foo.pack.gz"/> </dest> </cmp:gzip>
Creates a deflated Pack200 archive of foo.jarand stores it in the file foo.pack.gz in the project's basedir.