https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
o

Ola Adolfsson

11/21/2023, 5:17 PM
Hi! I have library that targets the JVM and JS. I would like to have function/API (runtime) to retrieve my artefact version. However, the version is only available in the gradle build scripts. Is there a smart way to inject the version to my code so that my consumers can retreive it?
f

Federico d'Alonzo

11/21/2023, 5:47 PM
You can use a Gradle plugin that generates a kotlin file containing the necessary data, like BuildKonfig which is for multiplatform projects.
o

Ola Adolfsson

11/25/2023, 5:39 PM
Thanks 🙂
I ended up reading the package.json with an expect/actual method. 🙂
require('../package.json').version