2021-06-25 13:45:16 +00:00
|
|
|
// Gradle build config for Godot Engine's Android port.
|
2022-05-31 18:10:15 +00:00
|
|
|
plugins {
|
|
|
|
id 'com.android.application'
|
|
|
|
id 'org.jetbrains.kotlin.android'
|
|
|
|
}
|
2021-06-25 13:45:16 +00:00
|
|
|
|
|
|
|
dependencies {
|
|
|
|
implementation libraries.kotlinStdLib
|
|
|
|
implementation libraries.androidxFragment
|
|
|
|
implementation project(":lib")
|
2022-06-01 06:26:03 +00:00
|
|
|
|
|
|
|
implementation "androidx.window:window:1.0.0"
|
2021-06-25 13:45:16 +00:00
|
|
|
}
|
|
|
|
|
2022-09-12 04:33:17 +00:00
|
|
|
ext {
|
2023-03-08 01:12:00 +00: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-12 04:33:17 +00:00
|
|
|
// Value by which the Godot version code should be offset by to make room for the build number
|
|
|
|
editorBuildNumberOffset = 100
|
2023-03-08 01:12:00 +00: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 04:33:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def generateVersionCode() {
|
|
|
|
int libraryVersionCode = getGodotLibraryVersionCode()
|
2023-03-08 01:12:00 +00:00
|
|
|
return (libraryVersionCode * editorBuildNumberOffset) + getEditorBuildNumber()
|
2022-09-12 04:33:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def generateVersionName() {
|
|
|
|
String libraryVersionName = getGodotLibraryVersionName()
|
2023-03-08 01:12:00 +00:00
|
|
|
int buildNumber = getEditorBuildNumber()
|
|
|
|
return buildNumber == 0 ? libraryVersionName : libraryVersionName + ".$buildNumber"
|
2022-09-12 04:33:17 +00:00
|
|
|
}
|
|
|
|
|
2021-06-25 13:45:16 +00: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.v3"
|
2022-09-12 04:33:17 +00:00
|
|
|
versionCode generateVersionCode()
|
|
|
|
versionName generateVersionName()
|
2021-06-25 13:45:16 +00:00
|
|
|
minSdkVersion versions.minSdk
|
2021-07-11 01:39:31 +00:00
|
|
|
targetSdkVersion versions.targetSdk
|
2021-06-25 13:45:16 +00:00
|
|
|
|
2022-02-17 01:30:33 +00:00
|
|
|
missingDimensionStrategy 'products', 'editor'
|
2023-03-08 01:12:00 +00:00
|
|
|
setProperty("archivesBaseName", "android_editor")
|
2021-06-25 13:45:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
compileOptions {
|
|
|
|
sourceCompatibility versions.javaVersion
|
|
|
|
targetCompatibility versions.javaVersion
|
|
|
|
}
|
|
|
|
|
2022-05-31 18:10:15 +00:00
|
|
|
kotlinOptions {
|
|
|
|
jvmTarget = versions.javaVersion
|
|
|
|
}
|
|
|
|
|
2023-03-08 01:12:00 +00:00
|
|
|
signingConfigs {
|
|
|
|
release {
|
|
|
|
storeFile getGodotKeystoreFile()
|
|
|
|
storePassword getGodotSigningPassword()
|
|
|
|
keyAlias getGodotKeyAlias()
|
|
|
|
keyPassword getGodotSigningPassword()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-25 13:45:16 +00:00
|
|
|
buildTypes {
|
2022-02-17 01:30:33 +00:00
|
|
|
dev {
|
|
|
|
initWith debug
|
|
|
|
applicationIdSuffix ".dev"
|
|
|
|
}
|
|
|
|
|
2021-06-25 13:45:16 +00:00
|
|
|
debug {
|
2022-02-17 01:30:33 +00:00
|
|
|
initWith release
|
|
|
|
|
2023-03-08 01:12:00 +00:00
|
|
|
applicationIdSuffix ".debug"
|
2022-02-17 01:30:33 +00:00
|
|
|
signingConfig signingConfigs.debug
|
2021-06-25 13:45:16 +00:00
|
|
|
}
|
|
|
|
|
2022-02-17 01:30:33 +00:00
|
|
|
release {
|
2023-03-08 01:12:00 +00:00
|
|
|
if (hasReleaseSigningConfigs()) {
|
|
|
|
signingConfig signingConfigs.release
|
|
|
|
}
|
2021-06-25 13:45:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
packagingOptions {
|
|
|
|
// 'doNotStrip' is enabled for development within Android Studio
|
|
|
|
if (shouldNotStrip()) {
|
|
|
|
doNotStrip '**/*.so'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|