C.80 TarTask
Prev | Appendix C. Optional tasks | Next

## C.80 TarTask

The `TarTask` creates a tarball from a fileset or directory.

Table C.110: Attributes

Name | Type | Description | Default | Required
--- | --- | --- | --- | ---
`destfile` | `String` | Tarball filename | none | Yes
`basedir` | `String` | Base directory to tar (if no fileset specified, entire directory contents will be included in tar) | none | No
`compression` | `String` | Type of compression to use (gzip, bzip2, none) | none | No
`includeemptydirs` | `Boolean` | If set to `true`, also empty directories are copied. | `true` | No
`longfile` | `String` | How to handle long files, those with a path > 100 chars. Allowable values are: `truncate` - paths are truncated to the maximum length, `fail` - paths greater than the maximim cause a build exception `warn` - paths greater than the maximum cause a warning and GNU is used, `gnu` - GNU extensions are used for any paths greater than the maximum, `omit` - paths greater than the maximum are omitted from the archive | warn | No
`prefix` | `String` | File path prefix to use when adding files to archive | none | No

### Note

files are not replaced if they are already present in the archive.

### Note

using basedir and fileset simultaneously can result in strange contents in the archive.

### C.80.1 Example

    <tar destfile="phing.tar">
     <fileset dir=".">
         <include name="**/**" />
     </fileset>
    </tar>

The above example uses a fileset to determine which files to include in the archive.

    <tar destfile="phing.tar.gz" basedir="." compression="gzip"/>

The second example uses the basedir attribute to include the contents of that directory (including subdirectories) in the archive, compressing the archive using gzip.

### C.80.2 Supported Nested Tags

- `fileset`

Prev | Up | Next
C.79 SymlinkTask | Home | C.81 ThrowTask