I know it's possible to set the version in build.gradle → nativeDistributions.packageVersion ...
but how does one read that version in the source code of the app, for example to print it in the application composable?
On macOs the about screen is available when opening the distributable app, and it shows the version we set via build.gradle:

You can try out the following, which will return the package version as String:
System.getProperty("jpackage.app-version")
Note: You should run your application using gradle runDistributable, otherwise the "jpackage.app-version" property will be null.
This will only work if you package and run either by jpackage or compose desktop plugin.
Other way to solve this is by using a Gradle task thst will generate Kotlin code containing the info you need from jpackage or Compose Desktop Gradle task
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With