2021-06-25 15:45:16 +02:00
|
|
|
// Gradle build config for Godot Engine's Android port.
|
2022-05-31 20:10:15 +02:00
|
|
|
plugins {
|
|
|
|
id 'com.android.application'
|
|
|
|
id 'org.jetbrains.kotlin.android'
|
2024-01-17 22:44:11 +01:00
|
|
|
id 'base'
|
2022-05-31 20:10:15 +02:00
|
|
|
}
|
2021-06-25 15:45:16 +02:00
|
|
|
|
|
|
|
dependencies {
|
2024-01-17 22:44:11 +01:00
|
|
|
implementation "androidx.fragment:fragment:$versions.fragmentVersion"
|
2021-06-25 15:45:16 +02:00
|
|
|
implementation project(":lib")
|
2022-06-01 08:26:03 +02:00
|
|
|
|
2024-01-17 22:44:11 +01:00
|
|
|
implementation "androidx.window:window:1.2.0"
|
2021-06-25 15:45:16 +02:00
|
|
|
}
|
|
|
|
|
2022-09-12 06:33:17 +02:00
|
|
|
ext {
|
2023-03-01 23:09:30 +01: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 {
|
2024-04-01 22:46:46 +02:00
|
|
|
buildNumber = Integer.parseInt(versionStatus.replaceAll("[^0-9]", ""))
|
2023-03-01 23:09:30 +01:00
|
|
|
} catch (NumberFormatException ignored) {
|
|
|
|
buildNumber = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return buildNumber
|
|
|
|
}
|
2022-09-12 06:33:17 +02:00
|
|
|
// Value by which the Godot version code should be offset by to make room for the build number
|
|
|
|
editorBuildNumberOffset = 100
|
2023-03-01 23:09:30 +01: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-12 06:33:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
def generateVersionCode() {
|
|
|
|
int libraryVersionCode = getGodotLibraryVersionCode()
|
2023-03-01 23:09:30 +01:00
|
|
|
return (libraryVersionCode * editorBuildNumberOffset) + getEditorBuildNumber()
|
2022-09-12 06:33:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
def generateVersionName() {
|
|
|
|
String libraryVersionName = getGodotLibraryVersionName()
|
2023-03-01 23:09:30 +01:00
|
|
|
int buildNumber = getEditorBuildNumber()
|
|
|
|
return buildNumber == 0 ? libraryVersionName : libraryVersionName + ".$buildNumber"
|
2022-09-12 06:33:17 +02:00
|
|
|
}
|
|
|
|
|
2021-06-25 15:45:16 +02:00
|
|
|
android {
|
|
|
|
compileSdkVersion versions.compileSdk
|
|
|
|
buildToolsVersion versions.buildTools
|
|
|
|
ndkVersion versions.ndkVersion
|
|
|
|
|
2024-01-17 22:44:11 +01:00
|
|
|
namespace = "org.godotengine.editor"
|
|
|
|
|
2021-06-25 15:45:16 +02:00
|
|
|
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-12 06:33:17 +02:00
|
|
|
versionCode generateVersionCode()
|
|
|
|
versionName generateVersionName()
|
2021-06-25 15:45:16 +02:00
|
|
|
minSdkVersion versions.minSdk
|
2021-07-11 03:39:31 +02:00
|
|
|
targetSdkVersion versions.targetSdk
|
2021-06-25 15:45:16 +02:00
|
|
|
|
|
|
|
missingDimensionStrategy 'products', 'editor'
|
2024-01-17 22:44:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
base {
|
|
|
|
archivesName = "android_editor"
|
2021-06-25 15:45:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
compileOptions {
|
|
|
|
sourceCompatibility versions.javaVersion
|
|
|
|
targetCompatibility versions.javaVersion
|
|
|
|
}
|
|
|
|
|
2022-05-31 20:10:15 +02:00
|
|
|
kotlinOptions {
|
|
|
|
jvmTarget = versions.javaVersion
|
|
|
|
}
|
|
|
|
|
2023-03-01 23:09:30 +01:00
|
|
|
signingConfigs {
|
|
|
|
release {
|
|
|
|
storeFile getGodotKeystoreFile()
|
|
|
|
storePassword getGodotSigningPassword()
|
|
|
|
keyAlias getGodotKeyAlias()
|
|
|
|
keyPassword getGodotSigningPassword()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-17 22:44:11 +01:00
|
|
|
buildFeatures {
|
|
|
|
buildConfig = true
|
|
|
|
}
|
|
|
|
|
2021-06-25 15:45:16 +02:00
|
|
|
buildTypes {
|
|
|
|
dev {
|
|
|
|
initWith debug
|
|
|
|
applicationIdSuffix ".dev"
|
|
|
|
}
|
|
|
|
|
|
|
|
debug {
|
|
|
|
initWith release
|
2023-03-01 23:09:30 +01:00
|
|
|
applicationIdSuffix ".debug"
|
2021-06-25 15:45:16 +02:00
|
|
|
signingConfig signingConfigs.debug
|
|
|
|
}
|
|
|
|
|
|
|
|
release {
|
2023-03-01 23:09:30 +01:00
|
|
|
if (hasReleaseSigningConfigs()) {
|
|
|
|
signingConfig signingConfigs.release
|
|
|
|
}
|
2021-06-25 15:45:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
packagingOptions {
|
|
|
|
// 'doNotStrip' is enabled for development within Android Studio
|
|
|
|
if (shouldNotStrip()) {
|
|
|
|
doNotStrip '**/*.so'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|