仅复制ant中不存在的文件
我正在将我的项目部署到要使用 java Web Start 进行部署的 Web 服务器。但是,Web Start 使用修改日期来确定是否再次下载资源(默认情况下)。
我想要的是一种仅部署那些尚不存在的(jar)文件的方法。这是通过在我的所有 jar 上添加构建版本号来实现的,因此 2 个同名的 jar 具有相同的内容。
注意:
- 由于从 svn 或 ivy 下载,jar 修改日期在构建中始终会较新(这就是我遇到此问题的原因)。
- 有一种方法可以使用 sun 的下载 servlet、更多文件等来执行此操作,但我'我很懒,不需要它,从长远来看,这个(更简单的)解决方案将更加稳健
I'm deploying my project to a web-server to be deployed with java Web Start. However, Web Start uses modification date to figure out whether to download the resources again (by default).
What I want is a way to only deploy those (jar) files that do not already exist. This is made possible by having build-version numbers on all my jars, so 2 jars with the same name have the same contents.
Notes:
- The jar modification dates will always be newer in the build (which is why I'm getting this problem), due to downloading from svn or ivy
- There's a way to do this using sun's download servlet, more files etc, but I'm lazy, don't need it, and this (simpler) solution will be more robust in the long term
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您正在使用 ants 复制任务(您没有明确表示您是),您可以尝试
present
选择器:http://ant.apache.org/manual/Types/selectors.html#presentselect。If you are using ants copy task (you don't explicitly say you are), you could try the
present
selector: http://ant.apache.org/manual/Types/selectors.html#presentselect.您可以尝试将
粒度
属性设置得非常,非常高,基本上禁用“如果源文件比目标文件新,则复制同名文件”功能。You could attempt to set the
granularity
attribute very, very high, to basically disable the "copy files with the same name if the source file is newer than the destination" feature.我们遇到了类似的问题,我最终实现了自己的 jar 任务来完成我需要的事情。 Ant 源代码是一个很好的起点;如果你幸运的话,你也许能够继承 Ant 的 jar 任务。它并不像听起来那么困难,而且比我尝试或考虑的六种解决方法要简单得多。
We had a similar problem, and I wound up implementing my own jar task to do what I needed. The Ant source code is a good place to start; if you're lucky you might be able to just subclass Ant's jar task. It's not nearly as difficult as it might sound, and was much more straightforward than the half dozen workarounds I tried or considered.
我们使用 Maven 和 JavaFX 和 WebStart 插件 在 JNLP 中保留 Maven 布局和版本,并且使用“非唯一”SNAPSHOT 将保留相同的 jar(忽略时间戳)。
我知道它是行家,所以对你不好,但有人可以尝试一下吗?
We solved this issue with maven and JavaFX and WebStart Plugin that keeps maven layout and version in the JNLP, and using "non-unique" SNAPSHOT will keep the same jar (ignoring the timestamp).
I know it's maven so not good for you, but someone may give it a try?