feat: Add version code and version name as a config - #507
farhaanbukhsh wants to merge 1 commit into
Conversation
Signed-off-by: Farhaan Bukhsh <farhaan@opencraft.com>
|
Thanks for the pull request, @farhaanbukhsh! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
| def appVersionCode = config.getOrDefault("VERSION_CODE", 1)?.toString() | ||
| def appVersionName = config.getOrDefault("VERSION_NAME", "1.0.0") | ||
|
|
||
| if (!(appVersionCode ==~ /[0-9]+/) || !appVersionCode.isInteger() || | ||
| appVersionCode.toInteger() < 1 || appVersionCode.toInteger() > 2100000000) { | ||
| throw new GradleException("VERSION_CODE must be an integer between 1 and 2100000000 in the YAML config.") | ||
| } |
There was a problem hiding this comment.
@farhaanbukhsh I am very confused here. Why are we converting VERSION_CODE to string, compare against a regex, check !isInt, to cast toInt and then validate the range?
Why can't we simply do?
def appVersionCode = config.getOrDefault("VERSION_CODE", 1)
if (!appVersionCode.isInteger() || appVersion < 1 || appVersion > 2100000000) {
throw...
}
Is it something with the way Gradle parses the YAML? Does it not preserve integers?
| targetSdk target_sdk_version | ||
| versionCode 1 | ||
| versionName "1.0.0" | ||
| versionCode appVersionCode.toInteger() |
There was a problem hiding this comment.
Related to above comment, why do we need to keep it as a string and cast to int every time we need this value?
Description
The PR helps to configure the version code and version name through config files since releasing the app always changing the code is cumbersome while doing that with a config variables makes life easier.
Testing instructions
Private Ref: https://tasks.opencraft.com/browse/BB-10453