shannah / jdeploy

Developer friendly desktop deployment tool
https://www.jdeploy.com
Apache License 2.0
355 stars 19 forks source link

Handling native dependencies #89

Open mipastgt opened 1 year ago

mipastgt commented 1 year ago

Unless I have missed something obvious here, I would like to make it a feature request to be able to handle native dependencies by providing a separate uber-jar for each target which was created outside of the build process of jdeploy and use jdeploy only for the installer generation and deployment part.

Discussed in https://github.com/shannah/jdeploy/discussions/88

Originally posted by **mipastgt** January 12, 2023 After reading all the documentation it is still not clear to me whether jdeploy can handle native dependencies. I have several jar files in my project which contain native shared libraries for one particular platform. E.g. something like mylib-macos-x64.jar. Putting all this into one large uber-jar would make it extremely big. Also my build framework already creates a platform specific uber-jar which works and I would just like to use that with jdeploy. Is that possible and if yes how?
shannah commented 1 year ago

I've been experimenting with adding support for install-time maven dependency resolution, which would give quite a bit of flexibility here. So far, I've added support for adding a list of maven dependencies (and repositories) to the package.json so that it will use Maven to resolve the app dependencies at the app's install time. This works well, but before releasing, I'm going to try to add support for adding a .jdeploy/maven/pom.xml file to your project which will be used (if present) for dependency resolution.

The benefits of this is that your app only needs to download what it needs on update/install - If only one library has changed, then it only needs to download that library.

Maven also makes it possible to download only the libraries for the current platform.

ETA a couple of weeks for preview.

mipastgt commented 1 year ago

I knew that "a couple" is not necessarily just two :-) but could you provide some update on this issue? I'd be interested to give it a try with a JetBrains Compose Desktop app which carries SQLite and the large Skia native library with it.

shannah commented 1 year ago

First, it is worth noting that jDeploy handles native dependencies find. You can bundle them in your jar files using the typical methods that developers normally use.

The issue here is one of efficiency - the desire to only package the native libs for the runtime platform.

This is where I've been experimenting with maven dependencies. I.e. downloading dependencies using maven, which allows it to only download the dependencies required for the current platform.

I got maven dependencies working but I'm not quite happy with some aspects of them yet. I am using them under the hood for the javafxVersion attribute (that allows you to expicitly set the javafx version).

Do you have a repository with a Jetbrains compose desktop app that I can try to get working with jDeploy?

mipastgt commented 1 year ago

Of course this is just an issue of efficiency but a critical one when the native parts are getting very large. The main problem here is the big native Skia library which is used for all rendering and which needs to shipped with the application somehow.

I have set up a little desktop example for you: https://github.com/mipastgt/PolySpiralDesktop

It already can create an uber-jar as shown in the readme. The setup follows the latest template from JetBrains.

Many thanks in advance for having a look into this issue. I think there could be a big market for jDeploy here if this issue could be resolved.

shannah commented 1 year ago

Thanks for the sample project. I'm working on being able to produce an executable jar file with it, but am hitting some issues. I've posted this question in the Jetpack compose forum:

https://github.com/JetBrains/compose-multiplatform/discussions/2952

mipastgt commented 1 year ago

It seems you just can't use wildcards in the manifest. See, e.g.: https://stackoverflow.com/questions/15930782/call-java-jar-myfile-jar-with-additional-classpath-option You will have to list all jars explicity. See also: https://docs.oracle.com/javase/tutorial/deployment/jar/downman.html