GUnzip/BUnzip2/UnXZ

說明

展開使用 GZip、BZip2 或 XZ 封裝的資源。

如果 dest 是目錄,則目標檔案的名稱與 src 相同(如果存在,則移除 .gz.bz2.xz 副檔名)。如果省略 dest,則採用 src 的父目錄。僅當來源資源較目標檔案新,或是目標檔案不存在時,才會展開檔案。

XZ 壓縮支援已新增於 Apache Ant 1.10.1 之後,且仰賴 Ant 發行版中未包含的外部程式庫。如需詳細資訊,請參閱 程式庫相依性

參數

屬性 說明 必要
src 要展開的檔案。 是,或巢狀資源集合
dest 目標檔案或目錄。

指定為巢狀元素的參數

任何 資源 或單一元素資源集合

指定的資源將用作 src

範例

test.tar.gz 展開至 test.tar

<gunzip src="test.tar.gz"/>

test.tar.bz2 展開至 test.tar

<bunzip2 src="test.tar.bz2"/>

test.tar.xz 展開至 test.tar

<unxz src="test.tar.xz"/>

test.tar.gz 展開至 test2.tar

<gunzip src="test.tar.gz" dest="test2.tar"/>

test.tar.gz 展開至 subdir/test.tar(假設 subdir 是目錄)。

<gunzip src="test.tar.gz" dest="subdir"/>

下載 https://example.org/archive.tar.gz 並將其即時展開至專案的 basedir 中的 archive.tar

<gunzip dest=".">
  <url url="https://example.org/archive.tar.gz"/>
</gunzip>

相關任務

下列

<gunzip src="some-archive.gz" dest="some-dest-dir"/>

<copy todir="some-dest-dir">
  <gzipresource>
    <file file="some-archive.gz"/>
  </gzipresource>
  <mapper type="glob" from="*.gz" to="*"/>
</copy>

相同。<bunzip2><bzip2resource><unxz><xzresource> 也是如此。<copy> 提供其他功能,例如即時 過濾檔案,允許將檔案對應至多個目標,保留最後修改時間或可設定的檔案系統時間戳記精細度。