How to get the application version programmatically in Compose Desktop?

Viewed 158

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: enter image description here

1 Answers

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.

Related