Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the application version programmatically in Compose Desktop?

I know it's possible to set the version in build.gradlenativeDistributions.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

like image 612
Ovi Trif Avatar asked May 29 '26 21:05

Ovi Trif


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.

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

like image 120
Eel Avatar answered Jun 01 '26 21:06

Eel