为什么每次构建时相同的JAR文件都具有不同的哈希值? [英] Why does the same JAR file have different hash every time I build it?

查看:330
本文介绍了为什么每次构建时相同的JAR文件都具有不同的哈希值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在考虑检查jar文件的哈希值以确定其是否已更改,但是事实证明,每次我构建时,同一jar文件具有不同的哈希值(从eclipse导出为jar文件,或它使用Maven).我已经删除了清单文件的日期值和内容,但仍然有所不同.字节码生成中是否包含时间戳或其他内容?

I've been thinking about checking jar file's hash value to determine if it has changed or not, but as it turns out the same jar file has different hashes every time I build it (export as jar file from eclipse, or build it using maven). I've removed manifest file's date values and stuff but it still is different. Is there something in bytecode generation which includes a timestamp or something?

推荐答案

JAR文件是一个ZIP文件,它的

A JAR file is a ZIP file and it contains a last modified date in its local file headers and central directory file header. This will lead to different hashes of your builds.

如果对完全相同的文件集(具有相同的文件日期)运行JAR命令,并跳过清单文件的创建,则应该为您提供完全相同的JAR文件(如果ZIP内文件的顺序不变).

If you run the JAR command on the exact same set of files (with same file dates) and skip manifest file creation it should give you the exact same JAR file (if the order of files inside the ZIP does not change).

这篇关于为什么每次构建时相同的JAR文件都具有不同的哈希值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆