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

白昼怎懂夜的黑 提交于 2020-12-12 11:05:58

问题


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:


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=<URL for updates.xml>

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("updatesUrl");

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.



来源:https://stackoverflow.com/questions/63109803/does-install4j-updater-support-multi-delivery-channels-stable-beta-nightly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!