Apache Ant Tasks - GZip



Description

Gzip task creates archive based on GZip, BZip2 or XZ algorithm. Output file is generated only if it is not present or source is newer.

Properties

Sr.No Attributes & Description
1

src

The file/collection to gzip/bzip/xz. (Mandatory)

2

Destfile

the destination file to create. (Mandatory)

Example

Usage

Create build.xml with the following content:

<?xml version="1.0"?>
<project name="TutorialPoint" default="info">
   <target name="info">
      <gzip src="test.txt" destfile="text.gz" />
      <echo>File archived.</echo>
   </target>
</project>

Output

Create a text.txt file with some content in the same folder. Now running Ant on the above build file produces the following output −

F:\tutorialspoint\ant>ant
Buildfile: F:\tutorialspoint\ant\build.xml

info:
     [gzip] Building: F:\tutorialspoint\ant\text.gz
     [echo] File archived.

BUILD SUCCESSFUL
Total time: 0 seconds

You can verify that the text.gz file created.

Advertisements