Closed VitaSokolova closed 10 months ago
Does this work?
appVersioning {
overrideVersionName { _, providers, _ ->
providers.gradleProperty("appVersionName").get()
}
overrideVersionCode { _, providers, _ ->
providers.gradleProperty("appVersionCode").get().toInt()
}
}
It was the first thing I tried, tbh, but it fails with error 😔
Execution failed for task ':app:generateAppVersionInfoForDebug'.
> A failure occurred while executing io.github.reactivecircus.appversioning.tasks.GenerateAppVersionInfoWorkAction
> Cannot query the value of this provider because it has no value available.
It works for me🤔 do the file and properties exist?
I found out, why it didn't work in my project. If I put my values at global gradle.properties
, everything works, but if I put them inside the app module's gradle.properties
, I receive the error above. In my repository we have two application modules, so using global gradle.properties
is not a good solution for us.
You can check on that test project if you run :freeflex:generateAppVersionInfoForDebug --rerun
https://github.com/VitaSokolova/AppVersioningSample
Project level gradle.properties
won't work: https://github.com/gradle/gradle/issues/13302
Maybe just put the version info in a regular file?
Seem like it's the simplest solution. Thanks for your help!
We use app-versioning for long time to bump up version code and adding branch name to the version name. When we had gradle scripts on Groovy everything worked fine. We had read latest values from
gradle.properties
and modified them if needed.gradle.properties
:Our app module
build.gradle
Now we are in process of migration to
.gradle.kts
files and we ran into an issue:The code we have:
Can you, please, explain how we can fetch current versionCode and versionName without addressing global variables? I saw similar issue opened, but our case seems to be much simpler and I assume many other developers can struggle with the same problem.