Uncompressing Tasks

Description

For each of the supported compression formats there is a correspondig task that uncompresses a resource. These tasks are based on their core cousin tasks.

If dest is a directory the name of the destination file is the same as src (with the compression specific extension removed if present). If dest is omitted, the parent dir of src is taken. The file is only expanded if the source resource is newer than the destination file, or when the destination file does not exist.

Parameters

Attribute Description Required
src the file to expand. Yes, or a nested resource collection.
dest the destination file or directory. No
decompressConcatenated Only for the formats that support files holding multiple compressed streams (bzip2, gzip and xz).
If set to true all streams will be concatenated and treated as a single resource. With the default value false only the first stream is uncompressed.
No

Parameters specified as nested elements

any resource or single element resource collection

The specified resource will be used as src.

BUnZip2

Is an uncompressing task that uses the BZIP2 compression algorithm.

This task supports the decompressConcatenated attribute.

GUnZip

Is an uncompressing task that uses the GZIP compression algorithm.

This task supports the decompressConcatenated attribute.

UnLZMA

Is an uncompressing task that uses the LZMA compression algorithm.

Unpack200

Is an uncompressing task that uses the Pack200 compression algorithm.

This task does not work on defalted archives, you need to wrap deflated archives into gunzipresources in order to use them.

Parameters

In addition to the attributes supported by all uncompressing 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.

Parameters specified as nested elements

In addition to the nested elements supported by all uncompressing task this task also supports.

property

Sets a property for the unpacker (see the Pack200 javadocs for details).

Attribute Description Required
key Name of the property. Yes.
value Value of the property. Yes.

UnSnappy

Is an uncompressing task that uses the Snappy compression algorithm.

Since Apache Compress Antlib 1.4.

Parameters

In addition to the attributes supported by all uncompressing task this task also supports.

Attribute Description Required
framed Whether the input is expected to use the framing format. No, defaults to true.

UnXZ

Is an uncompressing task that uses the XZ compression algorithm.

This task supports the decompressConcatenated attribute.

UnZ

Is an uncompressing task that uses the .Z compression algorithm.

Since Apache Compress Antlib 1.4.

Examples

<cmp:gunzip src="test.tar.gz" xmlns:cmp="antlib:org.apache.ant.compress"/>

expands test.tar.gz to test.tar

<cmp:bunzip2 src="test.tar.bz2" xmlns:cmp="antlib:org.apache.ant.compress"/>

expands test.tar.bz2 to test.tar

<cmp:gunzip src="test.tar.gz" dest="test2.tar" xmlns:cmp="antlib:org.apache.ant.compress"/>

expands test.tar.gz to test2.tar

<cmp:gunzip src="test.tar.gz" dest="subdir" xmlns:cmp="antlib:org.apache.ant.compress"/>

expands test.tar.gz to subdir/test.tar (assuming subdir is a directory).

<cmp:gunzip dest="." xmlns:cmp="antlib:org.apache.ant.compress">
  <url url="http://example.org/archive.tar.gz"/>
</cmp:gunzip>

downloads http://example.org/archive.tar.gz and expands it to archive.tar in the project's basedir on the fly.

<cmp:unpack200 dest="foo.jar" xmlns:cmp="antlib:org.apache.ant.compress">
  <cmp:gzipresource>
    <file file="foo.pack.gz"/>
  </cmp:gzipresource>
</cmp:unpack200>

Unpacks the deflated Pack200 archive foo.pack.gz and stores it as foo.jar.

Related tasks

<cmp:gunzip src="some-archive.gz" dest="some-dest-dir" xmlns:cmp="antlib:org.apache.ant.compress"/>
is identical to
<copy todir="some-dest-dir">
  <cmp:gzipresource xmlns:cmp="antlib:org.apache.ant.compress">
    <file file="some-archive.gz"/>
  </cmp:gzipresource>
  <mapper type="glob" from="*.gz" to="*"/>
</copy>

The same is also true for <bunzip2> and <bzip2resource>. <copy> offers additional features like filtering files on the fly, allowing a file to be mapped to multiple destinations, preserving the last modified time or a configurable file system timestamp granularity.