Closed mr3y-the-programmer closed 1 year ago
I think you want to avoid referencing anything external such as extensions
within the overrideVersionCode
lambda.
Also when using this plugin versionCode
shouldn't be set in android.defaultConfig
which is evaluated eagerly and thus defeats the purpose of computing the version code lazily.
The idea is the result of the overrideVersionCode
lambda is the single source of truth and the 3 parameters of the lambda should provide what you need to compute the versionCode.
My Use case is increasing the versionCode
property by 1 on each release, this is why I used extensions
to get the current versionCode
but this is not strictly required, if that defeats the purpose of computing the version code lazily, I can avoid it and I think I will compute the versionCode
using only the 3 parameters as you mentioned Thanks.
Follow up: After computing versionCode
lazily, running generateAppVersionInfoFor<Variant>
completes successfully without errors.
Could you show a code snippet how did you "compute versionCode
lazily"?
I'm getting the following error when running
./gradlew generateAppVersionInfoFor<Variant>
with gradle configuration cache disabled.And I'm getting the following 2 errors when running
./gradlew generateAppVersionInfoFor<Variant>
with gradle configuration cache enabled. the first error is the aforementioned one, and the the second one is:I thought that configuration cache problems were addressed at #24, but even when the configuration cache is disabled, the build still fails with the first error above.
Steps to reproduce: app-versioning: 1.3.1 Gradle: 8.2.1 AGP: 8.1.0
appVersioning
extension configuration in my app'sbuild.gradle.kts
:Run generateAppVersionInfo for any variant, for example
debug
:./gradlew generateAppVersionInfoForDebug
Additional Context: I reproduced it on my side project https://github.com/mr3y-the-programmer/Ludi as I was trying to automate the release process for it.