Move the versionCode and versionName into the gradle file.

Google itself says it is better to specify the versions in the gradle file:
https://developer.android.com/studio/publish/versioning.html

And it allow us the specify a specific versionCode by environment variable
instead of by modifying files.
This commit is contained in:
Matthieu Gautier 2017-05-22 17:35:48 +02:00
parent a0b4ed21a5
commit a0e08c9cee
2 changed files with 18 additions and 5 deletions

View File

@ -188,6 +188,8 @@ android {
buildConfigField "String", "ENFORCED_LANG", "\"\"" buildConfigField "String", "ENFORCED_LANG", "\"\""
resValue "string", "app_name", "Kiwix" resValue "string", "app_name", "Kiwix"
resValue "string", "app_search_string", "Search Kiwix" resValue "string", "app_search_string", "Search Kiwix"
versionCode 54
versionName "2.3"
} }
// Custom apps built from a json file, zim file and icon set // Custom apps built from a json file, zim file and icon set
map.each { name, directory -> map.each { name, directory ->
@ -227,9 +229,22 @@ android {
buildConfigField "String", "ZIM_FILE_NAME", "\"$filename\"" buildConfigField "String", "ZIM_FILE_NAME", "\"$filename\""
long length = zimfile.length() long length = zimfile.length()
buildConfigField "long", "ZIM_FILE_SIZE", "$length" buildConfigField "long", "ZIM_FILE_SIZE", "$length"
if (parsedJson.content_version_code != null) { if (project.hasProperty('version_code')) {
buildConfigField "int", "CONTENT_VERSION_CODE", "$parsedJson.content_version_code" def version_code = project.property('version_code')
versionCode version_code.toInteger()
versionName "$version_code"
} else { } else {
versionCode parsedJson.version_code.toInteger()
}
if (project.hasProperty('content_version_code')) {
def content_version_code = project.property('content_version_code')
buildConfigField "int", "CONTENT_VERSION_CODE", "$content_version_code"
} else if (parsedJson.content_version_code != null) {
buildConfigField "int", "CONTENT_VERSION_CODE", "$parsedJson.content_version_code"
} else if (project.hasProperty('version_code')) {
def version_code = project.property('version_code')
buildConfigField "int", "CONTENT_VERSION_CODE", "$version_code"
} else if (parsedJson.version_code != null) {
buildConfigField "int", "CONTENT_VERSION_CODE", "$parsedJson.version_code" buildConfigField "int", "CONTENT_VERSION_CODE", "$parsedJson.version_code"
} }
buildConfigField "String", "ENFORCED_LANG", "\"$parsedJson.enforced_lang\"" buildConfigField "String", "ENFORCED_LANG", "\"$parsedJson.enforced_lang\""

View File

@ -1,9 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.kiwix.kiwixmobile" package="org.kiwix.kiwixmobile"
android:installLocation="auto" android:installLocation="auto">
android:versionCode="54"
android:versionName="2.3">
<supports-screens <supports-screens
android:anyDensity="true" android:anyDensity="true"