8

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

Ovi Trif
  • 394
  • 4
  • 11
  • As a workaround, for now I'm providing an argument to the `nativeDistributions` with `args += listOf("-v=${rootProject.version}",)` and using that in release builds. – Ovi Trif Jun 19 '22 at 19:38

1 Answers1

1

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.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Ahmed Hnewa
  • 1,185
  • 1
  • 4
  • 14