## Apache Compress Antlib User Manual

This Antlib contains tasks and resources that provide compression/uncompression and archival/unarchival capabilities based on Apache Commons Compress. Using Apache Commons Compress 1.14 this Antlib supports gzip, bzip2, lzma standalone, xz, .Z, DEFLATE, Snappy, LZ4, Brotli and pack200 compression and ar, arj, cpio, 7z, Unix dump, tar and zip archives. Support for arj, .Z, Brotli and dump is read-only. 7z can only be used on filesystem resources.

### Known Limitations

Reading AR archives from non-filesystem resources currently fails for reasons that haven't been investigated, yet. Most likely the problem is within Apache Commons Compress.

### Tasks and Types

This Antlib contains the following tasks:

- ar
- bunzip2
- bzip2
- cpio
- deflate
- gunzip
- gzip
- lz4
- lzma
- pack200
- pack200normalize
- sevenz
- snappy
- tar
- un7z
- unar
- unarj
- unbrotli
- uncpio
- undeflate
- undump
- unlz4
- unlzma
- unpack200
- unsnappy
- untar
- unxz
- unz
- unzip
- xz
- zip

This Antlib contains the following resources:

- archives
- arentry
- arjentry
- arfileset
- arjfileset
- brotliresource
- bzip2resource
- cpioentry
- cpiofileset
- deflateresource
- dumpentry
- dumpfileset
- gzipresource
- lz4resource
- lzmaresource
- pack200resource
- snappyresource
- tarentry
- sevenzfileset
- sevenzentry
- tarfileset
- xzresource
- zipentry
- zipfileset
- zresource

This Antlib contains the following conditions that work on the `*entry`-resources of this Antlib as well as their counterparts in Ant itself:

- hasgroupid
- hasgroupname
- hasmode
- hasuserid
- hasusername

### Installing and Using

This Antlib requires Apache Ant 1.8.0 or higher, Apache Commons Compress 1.14 or higher and Java7 or higher.

In order to use LZMA, XZ or most of the 7z support the XZ for Java version 1.6 or later is required.

In order to use Brotli the Brotli dec library verision 0.1.2 or later is required.

If you are building the Antlib from sources, run the `antlib` target and you'll get a file `ant-compress-VERSION.jar`. If you've downloaded a binary release, you are already there.

In order to use the Antlib, you can either use `taskdef` or rely on Ant's autodiscovery by using an XML namespace and the Antlib's URI. The `taskdef` approach allows you to specify a custom classpath while you must make sure Ant finds the Antlib itself as well as Apache Commons Compress - either because it is in a well known place like `$ANT_HOME/lib` or using the `-lib` command line option - when using autodiscovey.

#### The `taskdef` approach

Before you can use any of the tasks or resources you must use a `taskdef` task like:

          <taskdef
            uri="antlib:org.apache.ant.compress"
            resource="org/apache/ant/compress/antlib.xml">
            <classpath>
              <pathelement location="YOUR-PATH-TO/ant-compress-VERSION1.jar"/>
              <pathelement location="YOUR-PATH-TO/commons-compress-VERSION2.jar"/>
              <!-- optional dependencies -->
              <pathelement location="YOUR-PATH-TO/xz-VERSION3.jar"/>
              <pathelement location="YOUR-PATH-TO/dec-VERSION4.jar"/>
            </classpath>
          </taskdef>

And later use something like:

          <comp:tar
            xmlns:tar="antlib:org.apache.ant.compress"
            ...

#### The autodiscovery approach

          <project
            xmlns:comp="antlib:org.apache.ant.compress"
            ...

And later use something like:

              <comp:tar
                ...