install4j 更新程序支持多个交付渠道(稳定版 / 测试版 / 每夜版)吗?

huangapple go评论78阅读模式
英文:

does install4j updater support multi delivery channels (stable / beta / nightly)?

问题

我正在使用install4j来打包我的Java应用程序。我为所有平台分发安装程序以及便携式存档。到目前为止,我一直在使用自行开发的更新机制,但这个机制在权限方面存在一些限制。我正在考虑将更新过程委托给Install4j,但我不确定它是否能够满足我的需求(至少我还没有找到如何实现我需要的功能)。我的应用程序具有以下功能:
- 用户可以选择交付渠道(稳定版/测试版/每夜版)
- 应用程序具有逻辑,可以根据渠道检查是否有更新,并指向正确的新构件
- 由于写入权限问题,我的应用程序在某些情况下无法完成更新过程

Install4j能够处理这样的用例吗?我需要使用所有更新参数调用install4j更新程序,因为我认为我无法通过单个update.xml文件实现我想要的效果。在阅读了文档后,我无法找到如何做到这一点,但考虑到多交付渠道是相当常见的,我认为我可能已经忽略了这一点。

非常感谢您提前的帮助,并指导我朝着正确的方向前进。

英文:

I am using install4j to package my java application. I distribute installers for all platforms along portable archives. So far, I have been using a self-developed update mechanism which has some limitations mostly related to permission rights. I am considering delegating the update process to Install4j but I am not sure it can deal with my needs (at least I haven't found how to achieve what I need). My app has the following feature:
- user can select a delivery channel (stable / beta /nightly)
- the app has the logic to check if an update is available based on the channel and to point to the right new artefacts
- my app fails the update process in some cases because of writing rights

Can Install4J manage such a use case? I would need to call install4j updater with all the update parameters as I don't think I can't achieve what I want with a single update.xml file. I could not find how to do it reading the documentation but considering multi-delivery channels is quite common I thought I might have missed it.

Thank you in advance for your help and pointing me in the right direction.

答案1

得分: 2

install4j中的更新下载器只是一个模板,您可以根据自己的需求进行修改。

在您的情况下,您需要为每个通道创建不同的updates.xml,例如updates_stable.xmlupdates_beta.xmlupdates_nightly.xml

更新下载器模板已经设置好了用于处理update.xml可变URL的功能。如果您找到“检查更新”操作,您将看到其“更新描述符URL”属性设置为

${installer:updatesUrl?:${compiler:sys.updatesUrl}}

这意味着如果安装程序变量updatesUrl已指定,将使用该值。如果没有(这是默认值),则使用编译器变量sys.updatesUrl的内容,该内容在“安装程序->更新选项”步骤上指定。

如果您使用以下参数启动更新下载器:

-VupdatesUrl=<更新.xml的URL>

则将设置并使用安装程序变量。

或者,您可以使用可持久的安装程序变量,可以在安装程序中设置,例如使用“设置变量”操作。在这种情况下,必须将变量写入响应文件。必须选择“设置变量”操作的“注册响应文件”属性,或者您必须调用

context.registerResponseFileVariable("updatesUrl");

然后,您必须在更新下载器的“启动”节点中添加“加载响应文件”操作,变量将自动设置为其持久化值。

还有另一种选择,即使用用户特定的首选项存储,这种情况下,您将在安装程序中使用“将安装程序变量保存到Java首选项存储”操作,并在更新下载器中使用“从Java首选项存储加载安装程序变量”操作来持久化安装程序变量的值。后一种方法的优点是,您可以在自己的代码中使用API

com.install4j.api.launcher.Variables.saveToPreferenceStore(...)

来更改变量值而无需提升特权。

英文:

The update downloader in install4j is just a template, you can modify it according to your own needs.

In your case, you need a different updates.xml for each channel, for example updates_stable.xml, updates_beta.xml and updates_nightly.xml.

The update downloader template is already set up to deal with variable URLs for update.xml. If you locate the "Check for update" action, you will see that its "Update descriptor URL" property is set to

${installer:updatesUrl?:${compiler:sys.updatesUrl}}

This means that if the installer variable updatesUrl is specified, that value is used. If not (this is the default), the content of the compiler variable sys.updatesUrl is used which is the value that is specified on the "Installer->Update options" step.

If you start the update downloader with the argument

-VupdatesUrl=&lt;URL for updates.xml&gt;

the installer variable is set and will be used.

Alternatively, you can use a persistent installer variable that can be set in the installer, for example with a "Set a variable" action. In that case, the variable has to be written to the response file. The "Register for response file" property of the "Set a variable" action has to be selected, or you have to call

context.registerResponseFileVariable(&quot;updatesUrl&quot;);

Then, you have to add a "Load a response file" action to the "Startup" node of the update downloader and the variable will be set automatically with its persisted value.

Yet another option is to use the user-specific preference store, in that case you would use a "Save installer variables to the Java preference store" action in the installer and a "Load installer variables from the Java preference store" action in the update downloader to persist the value of the installer variable. The latter approach has the advantage that you can use the API

com.install4j.api.launcher.Variables.saveToPreferenceStore(...)

in your own code to change the variable value without elevated privileges.

huangapple
  • 本文由 发表于 2020年7月27日 14:30:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/63109803.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定