Compressing Tasks

Description

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.

Parameters

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.

Parameters specified as nested elements

any resource or single element resource collection

The specified resource will be used as src.

any archiving task

The task's output will be used as src.

You must not specify the archiving task's dest attribute or nested element.

dest

Accepts any resource or single element resource collection as nested element.

The specified resource will be used as dest.

BZip2

Is an compressing task that uses the BZIP2 compression algorithm.

GZip

Is an compressing task that uses the GZIP compression algorithm.

Examples

    <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.