Fork me on GitHub
#cljfx
<
2022-01-14
>
grounded_sage14:01:01

Is there a good process for automatic updates? @vlaaad Taking a look it seems that jpackage doesn't offer this out of the box. I found update4j which seems like it might be a solution but have to dig further on that.

vlaaad14:01:29

Hi! Afaik, there is no good process for automatic updates. On the JVM level. When I was working on Defold editor (clj desktop app), we had to implement it ourselves. It also had some issues with overwriting files on Windows which is not allowed by os if it's executed

vlaaad14:01:49

@grounded_sage You can jpackage a clj tool instead of your actual app and make it lookup latest release and download + run it :D

vlaaad14:01:49

By clj tool I basically mean tools.deps library :)

grounded_sage14:01:24

Okay. Yea I guess that is a solution. Don't like it but don’t really see many if any options otherwise.

vlaaad14:01:10

Using tools-deps on a client is actually sorta kinda like browsers lookup/cache web app resources

👍 1
grounded_sage13:01:23

To dig a bit deeper on this for my comprehension. Do you mean being able to reference the source and build on the client or fetch the Jar/s. Or both. I'm not really sure yet what the different trade offs would be here. With payload size, client side compute, security.

vlaaad14:01:32

btw I've been thinking about using tools.deps a bit and I think there might be a problem with this approach, though it might be possible to side-step it — tools.deps uses systemwide git for git deps, end users might not have it

vlaaad14:01:15

I was thinking about fetching jars

vlaaad14:01:59

more specifically, lightweight jars instead of uberjars

vlaaad14:01:38

and tools-deps on end-user machine resolves all deps and caches them

grounded_sage09:01:28

Good point on the git. @skynet shared some code that does the Jar fetching. https://clojurians.slack.com/archives/CGHHJNENB/p1642196059014600?thread_ts=1642195307.013300&amp;channel=CGHHJNENB&amp;message_ts=1642196059.014600 Also mentioned it could be a library and I do think that would be valuable. At the very least a dedicated public repo would be a good way to aggregate some discussion and implementations on the best way to handle this.

vlaaad12:01:47

I’ve thought about it for a bit more and I see another downside — you can’t update the JDK

vlaaad12:01:40

that reminded me that we struggled with this in Defold where we needed to update the JDK — on Windows the OS held some files open and that disallowed overwriting them, so we had to install JDKs in different locations…

grounded_sage15:01:53

ah yes updating the JDK is another thing to consider.

grounded_sage16:01:47

This is what Electron is using it seems. https://github.com/Squirrel. I'm currently digging around to see if it's a viable solution.

grounded_sage16:01:39

I'm wondering if it's possible to do a GraalVM native binary which can be the installer. Was reading that JavaFX doesn't play nice with it but Gluon has it working.. we could then have a minimal custom UI and then handle installing the JRE and .jar separately.

grounded_sage16:01:18

Rereading what you said before... you managed to solve the JDK updates at Defold?

vlaaad19:01:08

that's the updater code, but every auto-updated system is 2 parts — client that downloads and release process... it's also there, but it's python, and deals with internal setup and aws and stuff

vlaaad14:01:04

Of course with the downside that it requires internet connection to start it the first time

grounded_sage20:01:26

I find this an acceptable trade off

grounded_sage17:01:51

Yea at the moment I have tools.build to build the jar file and also call on jpackage for the distributions. But going to have to rethink how I structure it because automatic updates is preferable.

skynet17:01:46

you can do auto updates even when using jpackage by replacing the .jar file. if you need to replace it somewhere that has special permissions on Windows you can use something like https://github.com/jpassing/elevate

grounded_sage21:01:47

Do you know any example projects in the wild that do this? @skynet I’ve done a bit of searching but at the moment think I'll just end up doing a bit of hacking next week. I come from more js environment so this whole environment is new to me

skynet21:01:19

I do it in a project here https://github.com/skynet-gh/skylobby/blob/a606f4d/src/clj/spring_lobby.clj#L2260-L2309 with some helper fns here https://github.com/skynet-gh/skylobby/blob/master/graal/clj/skylobby/util.clj#L477-L525 this works on Windows using the normal jpackage install run by .exe, but can also be used if running from a .jar

🙏 1
grounded_sage20:01:37

You've saved me hours of frustration. I'll be diving into the code deeper next week. Thank you.

skynet04:01:41

no problem, let me know if you have any issues. maybe there should be a library that does this kind of thing

grounded_sage09:01:19

Oh yea. I do think this would be a valuable library.

grounded_sage21:01:21

My thinking is definitely leaning towards having a minimal install updated shell and then just swapping out the jar for the remainder of the application