Hi! Can anyone tell me how to read value of librar...
# gradle
a
Hi! Can anyone tell me how to read value of library version from
libs.versions.toml
in kotlin file [need to send lib-version to BE]?
This is what I have tried so far, but I will need the version value in a different module(app or core).
```class AndroidxComposeVersion : Plugin<Project> {
override fun apply(target: Project) {
target.version()
}
}
fun Project.version(): String {
val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")
return libs.findVersion("androidxCompose").get().toString()
}```
c
Can't you just
libs.versions.androidxCompose.get()
?
a
I can only see examples with this approach used in gradle files, what I need to do is take the version of a library and send it to the backend.
Actually I can have something like this buildConfigField "String", "COMPOSE_VERSION", "\"${libs.versions.androidxCompose.get()}\"" and in kotlin file I can use BuildConfig.COMPOSE_VERSION Thanks for the suggestion!
m
Beware this will give you the declared version of the compose runtime. If any other library needs a more recent version, what you declare is not always what will end up being used at runtime