瀏覽代碼

Added version generation in release builds

Vadik Sirekanyan 7 年之前
父節點
當前提交
a18d8a529e
共有 2 個文件被更改,包括 17 次插入0 次删除
  1. 14 0
      app/build.gradle
  2. 3 0
      app/version

+ 14 - 0
app/build.gradle

@@ -27,6 +27,20 @@ android {
             applicationIdSuffix '.debug'
         }
     }
+    afterEvaluate {
+        assembleRelease.doLast {
+            applicationVariants.find { it.name == 'release' }.outputs.each { output ->
+                if (output.outputFile.exists()) {
+                    file("version").text =
+                            ['versionName': output.apkData.versionName,
+                             'versionCode': output.apkData.versionCode,
+                             'apkSize'    : "${(output.outputFile.size().toFloat() / 1024 / 1024).round(2)} MB"]
+                                    .collect { key, value -> "$key: $value\n" }
+                                    .join()
+                }
+            }
+        }
+    }
 }
 
 dependencies {

+ 3 - 0
app/version

@@ -0,0 +1,3 @@
+versionName: 0.2.1
+versionCode: 23
+apkSize: 3.33 MB