Zip / Jar文件中的二进制差异 [英] Binary Difference in Zip/Jar file

查看:276
本文介绍了Zip / Jar文件中的二进制差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎从完全相同的源文件构建jar或zip将始终产生不同的文件。我尝试使用java jar命令和ant中的jar和zip任务。

It seems like building a jar or zip from the exact same source files will always yield a different file. I tried this both using the java jar command, and the jar and zip tasks in ant.

这似乎是因为新的jar / zip具有时间戳设置为每个存储文件的当前时间。

It appears to be due to the fact that new jars/zips have the timestamp set to the current time on each stored file.

有没有办法强制拉链工具简单地使用文件系统上文件的时间戳,以确保从完全相同的源构建的jar将完全出现同样的?

Is there a way to force a zip tool to simply use the timestamp on the file on the filesystem to ensure that a jar built from the exact same source will appear exactly the same?

推荐答案

好的,我和同事想出了一个适合我们的解决方案。

Ok, a coworker and I came up with a solution that works for us.

我们不使用重新设计整个构建过程来删除任何类或jar文件,而是使用以下过程:

Instead of reengineering our entire build process to not delete any class or jar files, we use this procedure:


  1. 构建新工件。

  2. 使用jardiff( jnlp )来比较上一次构建的变化。

  3. 如果jardiff生成的差异jar没有变化,请从上一次构建获取工件。

  1. Build new artifacts.
  2. Use jardiff (part of jnlp) to compare changes from previous build.
  3. If the diff jar that jardiff produces has no changes, get artifact from previous build.

是的,我知道这听起来很糟糕,但它肯定会重写构建脚本以考虑到这一点。此外,我们可以在新机器上进行完全干净的构建(在服务器发生故障的情况下),此过程将确保仅生成实际更新的jar。

Yeah, I know it sounds kludgy, but it sure beats rewriting build script to take this into account. Also, we can do a completely clean build on a fresh machine (in the case of server failure), and this process will ensure that only actually updated jars are produced.

这篇关于Zip / Jar文件中的二进制差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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