📜  Apache Ant Zip任务

📅  最后修改于: 2020-12-26 14:06:24             🧑  作者: Mango

Apache Ant Zip任务

Ant Zip任务用于创建zip文件。 basedir属性用于引用从中创建zip文件的文件源。我们可以使用exclude属性来排除文件的压缩。

它创建一个隐式文件集,并支持各种嵌套元素,包括

Apache Ant Zip任务属性

Attribute Description Required
destfile Name of zip file to be created. Yes
basedir the directory from which to zip the files. No
compress Store and compress data as well. No
encoding The character encoding to use for filenames inside the zip file. No
filesonly It is used to store files entries only. No
includes A list of file to be include. No
excludes A list of files that must be excluded. No
update Update the destination file if it is already exists. No
whenempty behavior when no files match. Valid values are fail, skip, and create. No
duplicate behavior when a duplicate file is found. No
comment Comment to store in the archive. No
level Non-default level at which file compression should be performed. No
fallbacktoUTF8 Whether to use UTF-8 and the language encoding flag instead of the specified encoding. No
zip64Mode When to use Zip64 extensions for entries. No

让我们来看一些创建zip文件的示例。

Apache Ant Zip任务示例

通过从javatpoin / java目录收集所有文件来创建一个zip文件manual.zip。

    
    
        
    

如果存在zip文件,则会更新zip文件。

    
    
        
    

我们可以通过使用excludes属性指定文件名来排除文件。