Răsfoiți Sursa

Merge pull request #10724 from t895/auto-version-property

android: Use autoVersion when gradle property is set
bunnei 3 ani în urmă
părinte
comite
5a2e0d5b76
1 a modificat fișierele cu 15 adăugiri și 1 ștergeri
  1. 15 1
      src/android/app/build.gradle.kts

+ 15 - 1
src/android/app/build.gradle.kts

@@ -2,6 +2,7 @@
 // SPDX-License-Identifier: GPL-3.0-or-later
 // SPDX-License-Identifier: GPL-3.0-or-later
 
 
 import android.annotation.SuppressLint
 import android.annotation.SuppressLint
+import org.jetbrains.kotlin.konan.properties.Properties
 
 
 plugins {
 plugins {
     id("com.android.application")
     id("com.android.application")
@@ -57,9 +58,22 @@ android {
         applicationId = "org.yuzu.yuzu_emu"
         applicationId = "org.yuzu.yuzu_emu"
         minSdk = 30
         minSdk = 30
         targetSdk = 33
         targetSdk = 33
-        versionCode = 1
         versionName = getGitVersion()
         versionName = getGitVersion()
 
 
+        // If you want to use autoVersion for the versionCode, create a property in local.properties
+        // named "autoVersioned" and set it to "true"
+        val properties = Properties()
+        val versionProperty = try {
+            properties.load(project.rootProject.file("local.properties").inputStream())
+            properties.getProperty("autoVersioned") ?: ""
+        } catch (e: Exception) { "" }
+
+        versionCode = if (versionProperty == "true") {
+            autoVersion
+        } else {
+            1
+        }
+
         ndk {
         ndk {
             @SuppressLint("ChromeOsAbiSupport")
             @SuppressLint("ChromeOsAbiSupport")
             abiFilters += listOf("arm64-v8a")
             abiFilters += listOf("arm64-v8a")