如何防止蚂蚁创建具有不同哈希值的 zip?

How to prevent ant from creating zips with different hash?

我有一个构建脚本,用于创建使用 Ant 从 Gradle:

创建的 .zip 文件
ant.zip(destfile: targetFile) {
   fileset(dir: tempLocation) {
        include(name: "*/**")
   }
}

(基本上它调用了 Java Ant 库,仅此而已) 我的问题是,当我将同一个文件夹压缩两次时,两个 .zip 文件的哈希值不同。对于我们的构建管道,如果 2 个 zip 包含相同的文件(里面的文件完全相同),我需要它们具有相同的哈希值。任何人都知道如何做到这一点?

举个例子:
https://dl.dropboxusercontent.com/u/9186429/573.zip
对比
https://dl.dropboxusercontent.com/u/9186429/574.zip

编辑: 经过一些调查,事实证明 zip 文件存储文件的修改时间戳。 Ant压缩工具可以吗alter/remove这个?

我通过将修改日期设置为我压缩的所有文件的硬编码常量解决了这个问题:

file.setLastModified(Constants.defaultModifiedTime);
...
ant.zip {
...