| 
									
										
										
										
											2021-06-25 16:45:16 +03:00
										 |  |  | // Gradle build config for Godot Engine's Android port.
 | 
					
						
							| 
									
										
										
										
											2022-05-31 19:10:15 +01:00
										 |  |  | plugins { | 
					
						
							|  |  |  |     id 'com.android.application' | 
					
						
							|  |  |  |     id 'org.jetbrains.kotlin.android' | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-06-25 16:45:16 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | dependencies { | 
					
						
							|  |  |  |     implementation libraries.kotlinStdLib | 
					
						
							|  |  |  |     implementation libraries.androidxFragment | 
					
						
							|  |  |  |     implementation project(":lib") | 
					
						
							| 
									
										
										
										
											2022-05-31 23:26:03 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     implementation "androidx.window:window:1.0.0" | 
					
						
							| 
									
										
										
										
											2021-06-25 16:45:16 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-11 21:33:17 -07:00
										 |  |  | ext { | 
					
						
							| 
									
										
										
										
											2023-03-01 14:09:30 -08:00
										 |  |  |     // Retrieve the build number from the environment variable; default to 0 if none is specified.
 | 
					
						
							|  |  |  |     // The build number is added as a suffix to the version code for upload to the Google Play store.
 | 
					
						
							|  |  |  |     getEditorBuildNumber = { -> | 
					
						
							|  |  |  |         int buildNumber = 0 | 
					
						
							|  |  |  |         String versionStatus = System.getenv("GODOT_VERSION_STATUS") | 
					
						
							|  |  |  |         if (versionStatus != null && !versionStatus.isEmpty()) { | 
					
						
							|  |  |  |             try { | 
					
						
							|  |  |  |                 buildNumber = Integer.parseInt(versionStatus.replaceAll("[^0-9]", "")); | 
					
						
							|  |  |  |             } catch (NumberFormatException ignored) { | 
					
						
							|  |  |  |                 buildNumber = 0 | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return buildNumber | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-11 21:33:17 -07:00
										 |  |  |     // Value by which the Godot version code should be offset by to make room for the build number
 | 
					
						
							|  |  |  |     editorBuildNumberOffset = 100 | 
					
						
							| 
									
										
										
										
											2023-03-01 14:09:30 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Return the keystore file used for signing the release build.
 | 
					
						
							|  |  |  |     getGodotKeystoreFile = { -> | 
					
						
							|  |  |  |         def keyStore = System.getenv("GODOT_ANDROID_SIGN_KEYSTORE") | 
					
						
							|  |  |  |         if (keyStore == null) { | 
					
						
							|  |  |  |             return null | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return file(keyStore) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Return the key alias used for signing the release build.
 | 
					
						
							|  |  |  |     getGodotKeyAlias = { -> | 
					
						
							|  |  |  |         def kAlias = System.getenv("GODOT_ANDROID_KEYSTORE_ALIAS") | 
					
						
							|  |  |  |         return kAlias | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Return the password for the key used for signing the release build.
 | 
					
						
							|  |  |  |     getGodotSigningPassword = { -> | 
					
						
							|  |  |  |         def signingPassword = System.getenv("GODOT_ANDROID_SIGN_PASSWORD") | 
					
						
							|  |  |  |         return signingPassword | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Returns true if the environment variables contains the configuration for signing the release
 | 
					
						
							|  |  |  |     // build.
 | 
					
						
							|  |  |  |     hasReleaseSigningConfigs = { -> | 
					
						
							|  |  |  |         def keystoreFile = getGodotKeystoreFile() | 
					
						
							|  |  |  |         def keyAlias = getGodotKeyAlias() | 
					
						
							|  |  |  |         def signingPassword = getGodotSigningPassword() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return keystoreFile != null && keystoreFile.isFile() | 
					
						
							|  |  |  |             && keyAlias != null && !keyAlias.isEmpty() | 
					
						
							|  |  |  |             && signingPassword != null && !signingPassword.isEmpty() | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-11 21:33:17 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def generateVersionCode() { | 
					
						
							|  |  |  |     int libraryVersionCode = getGodotLibraryVersionCode() | 
					
						
							| 
									
										
										
										
											2023-03-01 14:09:30 -08:00
										 |  |  |     return (libraryVersionCode * editorBuildNumberOffset) + getEditorBuildNumber() | 
					
						
							| 
									
										
										
										
											2022-09-11 21:33:17 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def generateVersionName() { | 
					
						
							|  |  |  |     String libraryVersionName = getGodotLibraryVersionName() | 
					
						
							| 
									
										
										
										
											2023-03-01 14:09:30 -08:00
										 |  |  |     int buildNumber = getEditorBuildNumber() | 
					
						
							|  |  |  |     return buildNumber == 0 ? libraryVersionName : libraryVersionName + ".$buildNumber" | 
					
						
							| 
									
										
										
										
											2022-09-11 21:33:17 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-25 16:45:16 +03:00
										 |  |  | android { | 
					
						
							|  |  |  |     compileSdkVersion versions.compileSdk | 
					
						
							|  |  |  |     buildToolsVersion versions.buildTools | 
					
						
							|  |  |  |     ndkVersion versions.ndkVersion | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     defaultConfig { | 
					
						
							|  |  |  |         // The 'applicationId' suffix allows to install Godot 3.x(v3) and 4.x(v4) on the same device
 | 
					
						
							|  |  |  |         applicationId "org.godotengine.editor.v4" | 
					
						
							| 
									
										
										
										
											2022-09-11 21:33:17 -07:00
										 |  |  |         versionCode generateVersionCode() | 
					
						
							|  |  |  |         versionName generateVersionName() | 
					
						
							| 
									
										
										
										
											2021-06-25 16:45:16 +03:00
										 |  |  |         minSdkVersion versions.minSdk | 
					
						
							| 
									
										
										
										
											2021-07-10 18:39:31 -07:00
										 |  |  |         targetSdkVersion versions.targetSdk | 
					
						
							| 
									
										
										
										
											2021-06-25 16:45:16 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |         missingDimensionStrategy 'products', 'editor' | 
					
						
							| 
									
										
										
										
											2023-03-01 14:09:30 -08:00
										 |  |  |         setProperty("archivesBaseName", "android_editor") | 
					
						
							| 
									
										
										
										
											2021-06-25 16:45:16 +03:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     compileOptions { | 
					
						
							|  |  |  |         sourceCompatibility versions.javaVersion | 
					
						
							|  |  |  |         targetCompatibility versions.javaVersion | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-31 19:10:15 +01:00
										 |  |  |     kotlinOptions { | 
					
						
							|  |  |  |         jvmTarget = versions.javaVersion | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-01 14:09:30 -08:00
										 |  |  |     signingConfigs { | 
					
						
							|  |  |  |         release { | 
					
						
							|  |  |  |             storeFile getGodotKeystoreFile() | 
					
						
							|  |  |  |             storePassword getGodotSigningPassword() | 
					
						
							|  |  |  |             keyAlias getGodotKeyAlias() | 
					
						
							|  |  |  |             keyPassword getGodotSigningPassword() | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-25 16:45:16 +03:00
										 |  |  |     buildTypes { | 
					
						
							|  |  |  |         dev { | 
					
						
							|  |  |  |             initWith debug | 
					
						
							|  |  |  |             applicationIdSuffix ".dev" | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         debug { | 
					
						
							|  |  |  |             initWith release | 
					
						
							| 
									
										
										
										
											2023-03-01 14:09:30 -08:00
										 |  |  |             applicationIdSuffix ".debug" | 
					
						
							| 
									
										
										
										
											2021-06-25 16:45:16 +03:00
										 |  |  |             signingConfig signingConfigs.debug | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         release { | 
					
						
							| 
									
										
										
										
											2023-03-01 14:09:30 -08:00
										 |  |  |             if (hasReleaseSigningConfigs()) { | 
					
						
							|  |  |  |                 signingConfig signingConfigs.release | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-06-25 16:45:16 +03:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     packagingOptions { | 
					
						
							|  |  |  |         // 'doNotStrip' is enabled for development within Android Studio
 | 
					
						
							|  |  |  |         if (shouldNotStrip()) { | 
					
						
							|  |  |  |             doNotStrip '**/*.so' | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |