Install4j 自定义操作以合并新旧属性文件
在 install4j 中,我们可以为文件设置覆盖策略“如果更新,否则询问”或“始终询问”等。
我想升级一个具有最终用户可以编辑的 .properties 配置文件的应用程序。在较新的版本中,将添加一些属性,但我们不想更新自定义的现有属性。
因此,我将覆盖策略设置为“从不”,并创建一个自定义操作来合并新属性。我可以使用“将文本附加到文件”,但我想通过比较来更动态地执行此操作旧文件和新文件,并且仅附加旧文件中不存在键的那些属性。
所以我的问题是:
- 我可以检测在安装或升级过程中是否调用了该操作吗?
- 如果新文件没有覆盖旧文件,如何获取新文件的内容?
In install4j, we can set the Overwrite policy for a file "If newer, otherwise ask", or "Always ask", etc..
I want to upgrade an application which has a .properties configuration file that end users can edit. In newer versions, some properties will be added, but we don't want to update customized existing properties.
So I'd set the Overwrite policy to "never", and create a custom action to merge the new properties in. I could use the "Append text to a file", but I'd like to do it more dynamically, by comparing the old and the new file, and only append those properties whose keys do not exist in the old file.
So my questions:
- Can I detect if the action is called during an install or an upgrade?
- How can I get the content of the new file if it didn't overwrite the old file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
是的,您可以在条件表达式或其他脚本中
如果未安装文件,则无法访问其内容。我建议执行以下操作:
Yes, you can use
in condition expressions or other scripts.
If a file is not installed, the content is not accessible. I would suggest the following: