config.gradle 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. ext.versions = [
  2. androidGradlePlugin: '8.6.1',
  3. compileSdk : 35,
  4. // Also update:
  5. // - 'platform/android/export/export_plugin.cpp#DEFAULT_MIN_SDK_VERSION'
  6. // - 'platform/android/detect.py#get_min_target_api()'
  7. minSdk : 24,
  8. // Also update 'platform/android/export/export_plugin.cpp#DEFAULT_TARGET_SDK_VERSION'
  9. targetSdk : 35,
  10. buildTools : '35.0.0',
  11. kotlinVersion : '2.1.20',
  12. fragmentVersion : '1.8.6',
  13. nexusPublishVersion: '1.3.0',
  14. javaVersion : JavaVersion.VERSION_17,
  15. // Also update 'platform/android/detect.py#get_ndk_version()' when this is updated.
  16. ndkVersion : '28.1.13356709',
  17. splashscreenVersion: '1.0.1',
  18. openxrVendorsVersion: '4.0.0-stable'
  19. ]
  20. ext.getExportPackageName = { ->
  21. // Retrieve the app id from the project property set by the Godot build command.
  22. String appId = project.hasProperty("export_package_name") ? project.property("export_package_name") : ""
  23. // Check if the app id is valid, otherwise use the default.
  24. if (appId == null || appId.isEmpty()) {
  25. appId = "com.godot.game"
  26. }
  27. return appId
  28. }
  29. ext.getExportVersionCode = { ->
  30. String versionCode = project.hasProperty("export_version_code") ? project.property("export_version_code") : ""
  31. if (versionCode == null || versionCode.isEmpty()) {
  32. versionCode = "1"
  33. }
  34. try {
  35. return Integer.parseInt(versionCode)
  36. } catch (NumberFormatException ignored) {
  37. return 1
  38. }
  39. }
  40. ext.getExportVersionName = { ->
  41. String versionName = project.hasProperty("export_version_name") ? project.property("export_version_name") : ""
  42. if (versionName == null || versionName.isEmpty()) {
  43. versionName = "1.0"
  44. }
  45. return versionName
  46. }
  47. ext.getExportMinSdkVersion = { ->
  48. String minSdkVersion = project.hasProperty("export_version_min_sdk") ? project.property("export_version_min_sdk") : ""
  49. if (minSdkVersion == null || minSdkVersion.isEmpty()) {
  50. minSdkVersion = "$versions.minSdk"
  51. }
  52. try {
  53. return Integer.parseInt(minSdkVersion)
  54. } catch (NumberFormatException ignored) {
  55. return versions.minSdk
  56. }
  57. }
  58. ext.getExportTargetSdkVersion = { ->
  59. String targetSdkVersion = project.hasProperty("export_version_target_sdk") ? project.property("export_version_target_sdk") : ""
  60. if (targetSdkVersion == null || targetSdkVersion.isEmpty()) {
  61. targetSdkVersion = "$versions.targetSdk"
  62. }
  63. try {
  64. return Integer.parseInt(targetSdkVersion)
  65. } catch (NumberFormatException ignored) {
  66. return versions.targetSdk
  67. }
  68. }
  69. ext.getGodotLibraryVersionCode = { ->
  70. String versionName = ""
  71. int versionCode = 1
  72. (versionName, versionCode) = getGodotLibraryVersion()
  73. return versionCode
  74. }
  75. ext.getGodotLibraryVersionName = { ->
  76. String versionName = ""
  77. int versionCode = 1
  78. (versionName, versionCode) = getGodotLibraryVersion()
  79. return versionName
  80. }
  81. ext.generateGodotLibraryVersion = { List<String> requiredKeys ->
  82. // Attempt to read the version from the `version.py` file.
  83. String libraryVersionName = ""
  84. int libraryVersionCode = 0
  85. File versionFile = new File("../../../version.py")
  86. if (versionFile.isFile()) {
  87. def map = [:]
  88. List<String> lines = versionFile.readLines()
  89. for (String line in lines) {
  90. String[] keyValue = line.split("=")
  91. String key = keyValue[0].trim()
  92. String value = keyValue[1].trim().replaceAll("\"", "")
  93. if (requiredKeys.contains(key)) {
  94. if (!value.isEmpty()) {
  95. map[key] = value
  96. }
  97. requiredKeys.remove(key)
  98. }
  99. }
  100. if (requiredKeys.empty) {
  101. libraryVersionName = map.values().join(".")
  102. try {
  103. if (map.containsKey("status")) {
  104. int statusCode = 0
  105. String statusValue = map["status"]
  106. if (statusValue == null) {
  107. statusCode = 0
  108. } else if (statusValue.startsWith("dev")) {
  109. statusCode = 1
  110. } else if (statusValue.startsWith("alpha")) {
  111. statusCode = 2
  112. } else if (statusValue.startsWith("beta")) {
  113. statusCode = 3
  114. } else if (statusValue.startsWith("rc")) {
  115. statusCode = 4
  116. } else if (statusValue.startsWith("stable")) {
  117. statusCode = 5
  118. } else {
  119. statusCode = 0
  120. }
  121. libraryVersionCode = statusCode
  122. }
  123. if (map.containsKey("patch")) {
  124. libraryVersionCode += Integer.parseInt(map["patch"]) * 10
  125. }
  126. if (map.containsKey("minor")) {
  127. libraryVersionCode += (Integer.parseInt(map["minor"]) * 1000)
  128. }
  129. if (map.containsKey("major")) {
  130. libraryVersionCode += (Integer.parseInt(map["major"]) * 100000)
  131. }
  132. } catch (NumberFormatException ignore) {
  133. libraryVersionCode = 1
  134. }
  135. }
  136. }
  137. if (libraryVersionName.isEmpty()) {
  138. // Fallback value in case we're unable to read the file.
  139. libraryVersionName = "custom_build"
  140. }
  141. if (libraryVersionCode == 0) {
  142. libraryVersionCode = 1
  143. }
  144. return [libraryVersionName, libraryVersionCode]
  145. }
  146. ext.getGodotLibraryVersion = { ->
  147. List<String> requiredKeys = ["major", "minor", "patch", "status", "module_config"]
  148. return generateGodotLibraryVersion(requiredKeys)
  149. }
  150. ext.getGodotPublishVersion = { ->
  151. List<String> requiredKeys = ["major", "minor", "patch", "status"]
  152. String versionName = ""
  153. int versionCode = 1
  154. (versionName, versionCode) = generateGodotLibraryVersion(requiredKeys)
  155. if (!versionName.endsWith("stable")) {
  156. versionName += "-SNAPSHOT"
  157. }
  158. return versionName
  159. }
  160. final String VALUE_SEPARATOR_REGEX = "\\|"
  161. // get the list of ABIs the project should be exported to
  162. ext.getExportEnabledABIs = { ->
  163. String enabledABIs = project.hasProperty("export_enabled_abis") ? project.property("export_enabled_abis") : ""
  164. if (enabledABIs == null || enabledABIs.isEmpty()) {
  165. enabledABIs = "armeabi-v7a|arm64-v8a|x86|x86_64|"
  166. }
  167. Set<String> exportAbiFilter = []
  168. for (String abi_name : enabledABIs.split(VALUE_SEPARATOR_REGEX)) {
  169. if (!abi_name.trim().isEmpty()){
  170. exportAbiFilter.add(abi_name)
  171. }
  172. }
  173. return exportAbiFilter
  174. }
  175. ext.getExportPath = {
  176. String exportPath = project.hasProperty("export_path") ? project.property("export_path") : ""
  177. if (exportPath == null || exportPath.isEmpty()) {
  178. exportPath = "."
  179. }
  180. return exportPath
  181. }
  182. ext.getExportFilename = {
  183. String exportFilename = project.hasProperty("export_filename") ? project.property("export_filename") : ""
  184. if (exportFilename == null || exportFilename.isEmpty()) {
  185. exportFilename = "godot_android"
  186. }
  187. return exportFilename
  188. }
  189. ext.getExportEdition = {
  190. String exportEdition = project.hasProperty("export_edition") ? project.property("export_edition") : ""
  191. if (exportEdition == null || exportEdition.isEmpty()) {
  192. exportEdition = "standard"
  193. }
  194. return exportEdition
  195. }
  196. ext.getExportBuildType = {
  197. String exportBuildType = project.hasProperty("export_build_type") ? project.property("export_build_type") : ""
  198. if (exportBuildType == null || exportBuildType.isEmpty()) {
  199. exportBuildType = "debug"
  200. }
  201. return exportBuildType
  202. }
  203. ext.getExportFormat = {
  204. String exportFormat = project.hasProperty("export_format") ? project.property("export_format") : ""
  205. if (exportFormat == null || exportFormat.isEmpty()) {
  206. exportFormat = "apk"
  207. }
  208. return exportFormat
  209. }
  210. /**
  211. * Parse the project properties for the 'plugins_maven_repos' property and return the list
  212. * of maven repos.
  213. */
  214. ext.getGodotPluginsMavenRepos = { ->
  215. Set<String> mavenRepos = []
  216. // Retrieve the list of maven repos.
  217. if (project.hasProperty("plugins_maven_repos")) {
  218. String mavenReposProperty = project.property("plugins_maven_repos")
  219. if (mavenReposProperty != null && !mavenReposProperty.trim().isEmpty()) {
  220. for (String mavenRepoUrl : mavenReposProperty.split(VALUE_SEPARATOR_REGEX)) {
  221. mavenRepos += mavenRepoUrl.trim()
  222. }
  223. }
  224. }
  225. return mavenRepos
  226. }
  227. /**
  228. * Parse the project properties for the 'plugins_remote_binaries' property and return
  229. * it for inclusion in the build dependencies.
  230. */
  231. ext.getGodotPluginsRemoteBinaries = { ->
  232. Set<String> remoteDeps = []
  233. // Retrieve the list of remote plugins binaries.
  234. if (project.hasProperty("plugins_remote_binaries")) {
  235. String remoteDepsList = project.property("plugins_remote_binaries")
  236. if (remoteDepsList != null && !remoteDepsList.trim().isEmpty()) {
  237. for (String dep: remoteDepsList.split(VALUE_SEPARATOR_REGEX)) {
  238. remoteDeps += dep.trim()
  239. }
  240. }
  241. }
  242. return remoteDeps
  243. }
  244. /**
  245. * Parse the project properties for the 'plugins_local_binaries' property and return
  246. * their binaries for inclusion in the build dependencies.
  247. */
  248. ext.getGodotPluginsLocalBinaries = { ->
  249. Set<String> binDeps = []
  250. // Retrieve the list of local plugins binaries.
  251. if (project.hasProperty("plugins_local_binaries")) {
  252. String pluginsList = project.property("plugins_local_binaries")
  253. if (pluginsList != null && !pluginsList.trim().isEmpty()) {
  254. for (String plugin : pluginsList.split(VALUE_SEPARATOR_REGEX)) {
  255. binDeps += plugin.trim()
  256. }
  257. }
  258. }
  259. return binDeps
  260. }
  261. ext.getDebugKeystoreFile = { ->
  262. String keystoreFile = project.hasProperty("debug_keystore_file") ? project.property("debug_keystore_file") : ""
  263. if (keystoreFile == null || keystoreFile.isEmpty()) {
  264. keystoreFile = "."
  265. }
  266. return keystoreFile
  267. }
  268. ext.hasCustomDebugKeystore = { ->
  269. File keystoreFile = new File(getDebugKeystoreFile())
  270. return keystoreFile.isFile()
  271. }
  272. ext.getDebugKeystorePassword = { ->
  273. String keystorePassword = project.hasProperty("debug_keystore_password") ? project.property("debug_keystore_password") : ""
  274. if (keystorePassword == null || keystorePassword.isEmpty()) {
  275. keystorePassword = "android"
  276. }
  277. return keystorePassword
  278. }
  279. ext.getDebugKeyAlias = { ->
  280. String keyAlias = project.hasProperty("debug_keystore_alias") ? project.property("debug_keystore_alias") : ""
  281. if (keyAlias == null || keyAlias.isEmpty()) {
  282. keyAlias = "androiddebugkey"
  283. }
  284. return keyAlias
  285. }
  286. ext.getReleaseKeystoreFile = { ->
  287. String keystoreFile = project.hasProperty("release_keystore_file") ? project.property("release_keystore_file") : ""
  288. if (keystoreFile == null || keystoreFile.isEmpty()) {
  289. keystoreFile = "."
  290. }
  291. return keystoreFile
  292. }
  293. ext.getReleaseKeystorePassword = { ->
  294. String keystorePassword = project.hasProperty("release_keystore_password") ? project.property("release_keystore_password") : ""
  295. return keystorePassword
  296. }
  297. ext.getReleaseKeyAlias = { ->
  298. String keyAlias = project.hasProperty("release_keystore_alias") ? project.property("release_keystore_alias") : ""
  299. return keyAlias
  300. }
  301. ext.isAndroidStudio = { ->
  302. return project.hasProperty('android.injected.invoked.from.ide')
  303. }
  304. ext.shouldZipAlign = { ->
  305. String zipAlignFlag = project.hasProperty("perform_zipalign") ? project.property("perform_zipalign") : ""
  306. if (zipAlignFlag == null || zipAlignFlag.isEmpty()) {
  307. if (isAndroidStudio()) {
  308. zipAlignFlag = "true"
  309. } else {
  310. zipAlignFlag = "false"
  311. }
  312. }
  313. return Boolean.parseBoolean(zipAlignFlag)
  314. }
  315. ext.shouldSign = { ->
  316. String signFlag = project.hasProperty("perform_signing") ? project.property("perform_signing") : ""
  317. if (signFlag == null || signFlag.isEmpty()) {
  318. if (isAndroidStudio()) {
  319. signFlag = "true"
  320. } else {
  321. signFlag = "false"
  322. }
  323. }
  324. return Boolean.parseBoolean(signFlag)
  325. }
  326. ext.shouldNotStrip = { ->
  327. return isAndroidStudio() || project.hasProperty("doNotStrip")
  328. }
  329. ext.getAddonsDirectory = { ->
  330. String addonsDirectory = project.hasProperty("addons_directory") ? project.property("addons_directory") : ""
  331. return addonsDirectory
  332. }