jwharm / java-gi

GObject-Introspection bindings generator for Java
GNU Lesser General Public License v2.1
84 stars 7 forks source link

Platform-specific jars #59

Closed JFronny closed 1 year ago

JFronny commented 1 year ago

Due to the incompatibilities between platform-specific libraries and based on the discussion in #58, this PR introduces feature variants to provide platform-specific libraries. In user-facing applications, you are generally targeting only a single platform to provide proper installers, etc. so this should be OK there (see javagi-multiplatform for an example). For third party libraries, an api jar is also published. Currently, this is built for the linux platform and Gir merging/pruning (which would be needed for a proper api jar) are out of scope for this PR. The platform-specific gir files are obtained from the repo mentioned in #16. The repository from #16 does not currently contain all Gir files for GStreamer, meaning the GStreamer module is incomplete with this currently (which is why this PR is a draft). @badcel could those additional files be added there?

PS: the api jar is also required internally as a scaffold to build our own classes (like ValueUtil, GErrorException or ListIndexModel)

badcel commented 1 year ago

New files can be added. The only requirement is that the files are available on all 3 platforms.

In the repo there is a GitHub action which runs once per week and checks if there are updates available and automatically creates a PR if this is the case. This script must be functional for the new files.


Edit: actually the files must not be available on all 3 platforms as e.g. WebKit is only available for Linux, too.

jwharm commented 1 year ago

I don't think the missing GStreamer gir files are a huge issue. The base files are all there. @JFronny I will test this in the coming days.

jwharm commented 1 year ago

This is exactly what I hoped for, @JFronny thank you very much for implementing this. My tests still run fine, the only thing that seems to be broken is that IntelliJ complains it cannot find the source files in the GLib module. I'll try recreating the project to see if that helps.

For every module, there's a small jar file created without a postfix (for example, glib-1.2.10-0.5.jar) that is empty for adwaita and gstreamer, and only contains the java-gi source code for glib and gtk. Is that jar necessary in the build process or can it be skipped/removed? Anyway, it's easy to ignore it, so it's no big deal.

I will put the merging/pruning of the Gir files into the common denominator, on my todo list. That should not be too difficult, I can parse all three platform sources into a GirElement tree, and then filter the elements that are platform-specific. I will probably rename the api jar to common-api sometime; I think that would be a bit more descriptive.