Flatpak: how to keep your development tools at runtime
Running MicroOS as my daily on the work laptop is quite the experience. Nothing ever breaks but at the same time there is very little that can. This is because the apps I need are not packaged. Sad.
Over time I have packaged what I need but one of them took some time. VisualVM is a GUI to troubleshoot your Java processes, as it requires the Java SDK and Java SRE at runtime I was not sure how to package it.
Development tools and libraries are available at build time but applications are not shipped with them. Turns out that it was easy but almost undocumented so here we are. I will give bits and pieces of the manifest I made and explain what parts where necessary to have access to the Java SDK and Java JRE at runtime so that others may do the same.
The Flatpak build process is isolated in a sandbox and this means that we have access to almost nothing. What we need to build the app must be brough into the sandbox. This is where the sdk image comes in. The sdk image is a file-system with lots of development tools that can be used by flatpak at build times. The problem for us is that it does not have /all the tools/.
The sdk image does not provide a Java SDK and Java JRE so you cannot build your Java applications as is. The sanctioned way to do build a Java app is to use a sdk image extension. Following is the incantation to use the openjdk extension.
The extension provides the (Java) tools and libraries we need at build time but we also want them available at runtime. As this is a sensible use-case the publishers of the sdk extension have included a script to install everything in the final artifact that we produce. Following is the incanation to do so.
Now tools like javac
will be available both at build time and runtime.
Everything we need will be copied in the /app
directory. If the packaged
app requires the tools we can point it there and everything will work as
expected.
Following is the manifest that I have used to package VisualVM.