123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- ext.versions = [
- androidGradlePlugin: '7.0.3',
- compileSdk : 30,
- minSdk : 19, // Also update 'platform/android/java/lib/AndroidManifest.xml#minSdkVersion' & 'platform/android/export/export_plugin.cpp#DEFAULT_MIN_SDK_VERSION'
- targetSdk : 30, // Also update 'platform/android/java/lib/AndroidManifest.xml#targetSdkVersion' & 'platform/android/export/export_plugin.cpp#DEFAULT_TARGET_SDK_VERSION'
- buildTools : '30.0.3',
- kotlinVersion : '1.6.10',
- fragmentVersion : '1.3.6',
- javaVersion : 11,
- ndkVersion : '21.4.7075529' // Also update 'platform/android/detect.py#get_project_ndk_version()' when this is updated.
- ]
- ext.libraries = [
- androidGradlePlugin: "com.android.tools.build:gradle:$versions.androidGradlePlugin",
- kotlinGradlePlugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlinVersion",
- kotlinStdLib : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$versions.kotlinVersion",
- androidxFragment : "androidx.fragment:fragment:$versions.fragmentVersion",
- ]
- ext.getExportPackageName = { ->
- // Retrieve the app id from the project property set by the Godot build command.
- String appId = project.hasProperty("export_package_name") ? project.property("export_package_name") : ""
- // Check if the app id is valid, otherwise use the default.
- if (appId == null || appId.isEmpty()) {
- appId = "com.godot.game"
- }
- return appId
- }
- ext.getExportVersionCode = { ->
- String versionCode = project.hasProperty("export_version_code") ? project.property("export_version_code") : ""
- if (versionCode == null || versionCode.isEmpty()) {
- versionCode = "1"
- }
- try {
- return Integer.parseInt(versionCode)
- } catch (NumberFormatException ignored) {
- return 1
- }
- }
- ext.getExportVersionName = { ->
- String versionName = project.hasProperty("export_version_name") ? project.property("export_version_name") : ""
- if (versionName == null || versionName.isEmpty()) {
- versionName = "1.0"
- }
- return versionName
- }
- ext.getExportMinSdkVersion = { ->
- String minSdkVersion = project.hasProperty("export_version_min_sdk") ? project.property("export_version_min_sdk") : ""
- if (minSdkVersion == null || minSdkVersion.isEmpty()) {
- minSdkVersion = "$versions.minSdk"
- }
- try {
- return Integer.parseInt(minSdkVersion)
- } catch (NumberFormatException ignored) {
- return versions.minSdk
- }
- }
- ext.getExportTargetSdkVersion = { ->
- String targetSdkVersion = project.hasProperty("export_version_target_sdk") ? project.property("export_version_target_sdk") : ""
- if (targetSdkVersion == null || targetSdkVersion.isEmpty()) {
- targetSdkVersion = "$versions.targetSdk"
- }
- try {
- return Integer.parseInt(targetSdkVersion)
- } catch (NumberFormatException ignored) {
- return versions.targetSdk
- }
- }
- ext.getGodotEditorVersion = { ->
- String editorVersion = project.hasProperty("godot_editor_version") ? project.property("godot_editor_version") : ""
- if (editorVersion == null || editorVersion.isEmpty()) {
- // Try the library version first
- editorVersion = getGodotLibraryVersion()
- if (editorVersion.isEmpty()) {
- // Fallback value.
- editorVersion = "custom_build"
- }
- }
- return editorVersion
- }
- ext.generateGodotLibraryVersion = { List<String> requiredKeys ->
- // Attempt to read the version from the `version.py` file.
- String libraryVersion = ""
- File versionFile = new File("../../../version.py")
- if (versionFile.isFile()) {
- def map = [:]
- List<String> lines = versionFile.readLines()
- for (String line in lines) {
- String[] keyValue = line.split("=")
- String key = keyValue[0].trim()
- String value = keyValue[1].trim().replaceAll("\"", "")
- if (requiredKeys.contains(key)) {
- if (!value.isEmpty()) {
- map[key] = value
- }
- requiredKeys.remove(key)
- }
- }
- if (requiredKeys.empty) {
- libraryVersion = map.values().join(".")
- }
- }
- if (libraryVersion.isEmpty()) {
- // Fallback value in case we're unable to read the file.
- libraryVersion = "custom_build"
- }
- return libraryVersion
- }
- ext.getGodotLibraryVersion = { ->
- List<String> requiredKeys = ["major", "minor", "patch", "status", "module_config"]
- return generateGodotLibraryVersion(requiredKeys)
- }
- ext.getGodotPublishVersion = { ->
- List<String> requiredKeys = ["major", "minor", "patch", "status"]
- return generateGodotLibraryVersion(requiredKeys)
- }
- final String VALUE_SEPARATOR_REGEX = "\\|"
- // get the list of ABIs the project should be exported to
- ext.getExportEnabledABIs = { ->
- String enabledABIs = project.hasProperty("export_enabled_abis") ? project.property("export_enabled_abis") : "";
- if (enabledABIs == null || enabledABIs.isEmpty()) {
- enabledABIs = "armeabi-v7a|arm64-v8a|x86|x86_64|"
- }
- Set<String> exportAbiFilter = [];
- for (String abi_name : enabledABIs.split(VALUE_SEPARATOR_REGEX)) {
- if (!abi_name.trim().isEmpty()){
- exportAbiFilter.add(abi_name);
- }
- }
- return exportAbiFilter;
- }
- ext.getExportPath = {
- String exportPath = project.hasProperty("export_path") ? project.property("export_path") : ""
- if (exportPath == null || exportPath.isEmpty()) {
- exportPath = "."
- }
- return exportPath
- }
- ext.getExportFilename = {
- String exportFilename = project.hasProperty("export_filename") ? project.property("export_filename") : ""
- if (exportFilename == null || exportFilename.isEmpty()) {
- exportFilename = "godot_android"
- }
- return exportFilename
- }
- /**
- * Parse the project properties for the 'plugins_maven_repos' property and return the list
- * of maven repos.
- */
- ext.getGodotPluginsMavenRepos = { ->
- Set<String> mavenRepos = []
- // Retrieve the list of maven repos.
- if (project.hasProperty("plugins_maven_repos")) {
- String mavenReposProperty = project.property("plugins_maven_repos")
- if (mavenReposProperty != null && !mavenReposProperty.trim().isEmpty()) {
- for (String mavenRepoUrl : mavenReposProperty.split(VALUE_SEPARATOR_REGEX)) {
- mavenRepos += mavenRepoUrl.trim()
- }
- }
- }
- return mavenRepos
- }
- /**
- * Parse the project properties for the 'plugins_remote_binaries' property and return
- * it for inclusion in the build dependencies.
- */
- ext.getGodotPluginsRemoteBinaries = { ->
- Set<String> remoteDeps = []
- // Retrieve the list of remote plugins binaries.
- if (project.hasProperty("plugins_remote_binaries")) {
- String remoteDepsList = project.property("plugins_remote_binaries")
- if (remoteDepsList != null && !remoteDepsList.trim().isEmpty()) {
- for (String dep: remoteDepsList.split(VALUE_SEPARATOR_REGEX)) {
- remoteDeps += dep.trim()
- }
- }
- }
- return remoteDeps
- }
- /**
- * Parse the project properties for the 'plugins_local_binaries' property and return
- * their binaries for inclusion in the build dependencies.
- */
- ext.getGodotPluginsLocalBinaries = { ->
- Set<String> binDeps = []
- // Retrieve the list of local plugins binaries.
- if (project.hasProperty("plugins_local_binaries")) {
- String pluginsList = project.property("plugins_local_binaries")
- if (pluginsList != null && !pluginsList.trim().isEmpty()) {
- for (String plugin : pluginsList.split(VALUE_SEPARATOR_REGEX)) {
- binDeps += plugin.trim()
- }
- }
- }
- return binDeps
- }
- ext.getDebugKeystoreFile = { ->
- String keystoreFile = project.hasProperty("debug_keystore_file") ? project.property("debug_keystore_file") : ""
- if (keystoreFile == null || keystoreFile.isEmpty()) {
- keystoreFile = "."
- }
- return keystoreFile
- }
- ext.hasCustomDebugKeystore = { ->
- File keystoreFile = new File(getDebugKeystoreFile())
- return keystoreFile.isFile()
- }
- ext.getDebugKeystorePassword = { ->
- String keystorePassword = project.hasProperty("debug_keystore_password") ? project.property("debug_keystore_password") : ""
- if (keystorePassword == null || keystorePassword.isEmpty()) {
- keystorePassword = "android"
- }
- return keystorePassword
- }
- ext.getDebugKeyAlias = { ->
- String keyAlias = project.hasProperty("debug_keystore_alias") ? project.property("debug_keystore_alias") : ""
- if (keyAlias == null || keyAlias.isEmpty()) {
- keyAlias = "androiddebugkey"
- }
- return keyAlias
- }
- ext.getReleaseKeystoreFile = { ->
- String keystoreFile = project.hasProperty("release_keystore_file") ? project.property("release_keystore_file") : ""
- if (keystoreFile == null || keystoreFile.isEmpty()) {
- keystoreFile = "."
- }
- return keystoreFile
- }
- ext.getReleaseKeystorePassword = { ->
- String keystorePassword = project.hasProperty("release_keystore_password") ? project.property("release_keystore_password") : ""
- return keystorePassword
- }
- ext.getReleaseKeyAlias = { ->
- String keyAlias = project.hasProperty("release_keystore_alias") ? project.property("release_keystore_alias") : ""
- return keyAlias
- }
- ext.isAndroidStudio = { ->
- def sysProps = System.getProperties()
- return sysProps != null && sysProps['idea.platform.prefix'] != null
- }
- ext.shouldZipAlign = { ->
- String zipAlignFlag = project.hasProperty("perform_zipalign") ? project.property("perform_zipalign") : ""
- if (zipAlignFlag == null || zipAlignFlag.isEmpty()) {
- if (isAndroidStudio()) {
- zipAlignFlag = "true"
- } else {
- zipAlignFlag = "false"
- }
- }
- return Boolean.parseBoolean(zipAlignFlag)
- }
- ext.shouldSign = { ->
- String signFlag = project.hasProperty("perform_signing") ? project.property("perform_signing") : ""
- if (signFlag == null || signFlag.isEmpty()) {
- if (isAndroidStudio()) {
- signFlag = "true"
- } else {
- signFlag = "false"
- }
- }
- return Boolean.parseBoolean(signFlag)
- }
- ext.shouldNotStrip = { ->
- return isAndroidStudio() || project.hasProperty("doNotStrip")
- }
|