Apache Ant Tasks 简明教程

Apache Ant Tasks - GZip

Description

Gzip 任务基于 GZip、BZip2 或 XZ 算法创建存档。仅当它不存在或者源文件较新时才会生成输出文件。

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

使用以下内容创建 build.xml:

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

在同一文件夹中创建包含一些内容的 text.txt 文件。现在在上述构建文件上运行 Ant 会产生以下输出 −

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

你可以验证已创建 text.gz 文件。

You can verify that the text.gz file created.