Skip to content
0.2.0-dev Download ZIP
423 lines ·14.0 KB Raw
1ext.versions = [
2 androidGradlePlugin: '8.13.2',
3 compileSdk : 36,
4 // Also update:
5 // - 'editor/export/android_sdk_manager.h#DEFAULT_MIN_SDK_VERSION'
6 // - 'platform/android/detect.py#get_min_target_api()'
7 minSdk : 24,
8 // Also update 'editor/export/android_sdk_manager.h#DEFAULT_TARGET_SDK_VERSION'.
9 targetSdk : 36,
10 // Also update 'editor/export/android_sdk_manager.cpp#ANDROID_SDK_PACKAGES[build-tools]'.
11 buildTools : '36.1.0',
12 kotlinVersion : '2.1.21',
13 fragmentVersion : '1.8.6',
14 nexusPublishVersion: '1.3.0',
15 // Also update 'editor/export/android_sdk_manager.h#DEFAULT_JAVA_VERSION'.
16 javaVersion : JavaVersion.VERSION_17,
17 // Also update:
18 // - 'editor/export/android_sdk_manager.cpp#ANDROID_NDK_PACKAGES[ndk]'
19 // - 'platform/android/detect.py#get_ndk_version()'
20 ndkVersion : '29.0.14206865',
21 splashscreenVersion: '1.0.1',
22 // 'openxrLoaderVersion' should be set to XR_CURRENT_API_VERSION, see 'thirdparty/openxr'
23 openxrLoaderVersion: '1.1.63',
24 openxrVendorsVersion: '5.2.0-rc1-SNAPSHOT',
25 junitVersion : '1.3.0',
26 espressoCoreVersion: '3.7.0',
27 kotlinTestVersion : '1.3.11',
28 testRunnerVersion : '1.7.0',
29 testOrchestratorVersion: '1.6.1',
30 documentfileVersion: '1.1.0',
31]
32
33ext.getExportPackageName = { ->
34 // Retrieve the app id from the project property set by the Godot build command.
35 String appId = project.hasProperty("export_package_name") ? project.property("export_package_name") : ""
36 // Check if the app id is valid, otherwise use the default.
37 if (appId == null || appId.isEmpty()) {
38 appId = "com.godot.game"
39 }
40 return appId
41}
42
43ext.getExportVersionCode = { ->
44 String versionCode = project.hasProperty("export_version_code") ? project.property("export_version_code") : ""
45 if (versionCode == null || versionCode.isEmpty()) {
46 versionCode = "1"
47 }
48 try {
49 return Integer.parseInt(versionCode)
50 } catch (NumberFormatException ignored) {
51 return 1
52 }
53}
54
55ext.getExportVersionName = { ->
56 String versionName = project.hasProperty("export_version_name") ? project.property("export_version_name") : ""
57 if (versionName == null || versionName.isEmpty()) {
58 versionName = "1.0"
59 }
60 return versionName
61}
62
63ext.getExportMinSdkVersion = { ->
64 String minSdkVersion = project.hasProperty("export_version_min_sdk") ? project.property("export_version_min_sdk") : ""
65 if (minSdkVersion == null || minSdkVersion.isEmpty()) {
66 minSdkVersion = "$versions.minSdk"
67 }
68 try {
69 return Integer.parseInt(minSdkVersion)
70 } catch (NumberFormatException ignored) {
71 return versions.minSdk
72 }
73}
74
75ext.getExportTargetSdkVersion = { ->
76 String targetSdkVersion = project.hasProperty("export_version_target_sdk") ? project.property("export_version_target_sdk") : ""
77 if (targetSdkVersion == null || targetSdkVersion.isEmpty()) {
78 targetSdkVersion = "$versions.targetSdk"
79 }
80 try {
81 return Integer.parseInt(targetSdkVersion)
82 } catch (NumberFormatException ignored) {
83 return versions.targetSdk
84 }
85}
86
87ext.getGodotLibraryVersionCode = { ->
88 String versionName = ""
89 int versionCode = 1
90 (versionName, versionCode) = getGodotLibraryVersion()
91 return versionCode
92}
93
94ext.getGodotLibraryVersionName = { ->
95 String versionName = ""
96 int versionCode = 1
97 (versionName, versionCode) = getGodotLibraryVersion()
98 return versionName
99}
100
101ext.generateGodotLibraryVersion = { List<String> requiredKeys ->
102 // Attempt to read the version from the `version.py` file.
103 String libraryVersionName = ""
104 int libraryVersionCode = 0
105
106 File versionFile = new File("../../../version.py")
107 if (versionFile.isFile()) {
108 def map = [:]
109
110 List<String> lines = versionFile.readLines()
111 for (String line in lines) {
112 String[] keyValue = line.split("=")
113 String key = keyValue[0].trim()
114 String value = keyValue[1].trim().replaceAll("\"", "")
115
116 if (requiredKeys.contains(key)) {
117 if (!value.isEmpty()) {
118 map[key] = value
119 }
120 requiredKeys.remove(key)
121 }
122 }
123
124 if (requiredKeys.empty) {
125 libraryVersionName = map.values().join(".")
126 try {
127 if (map.containsKey("status")) {
128 int statusCode = 0
129 String statusValue = map["status"]
130 if (statusValue == null) {
131 statusCode = 0
132 } else if (statusValue.startsWith("dev")) {
133 statusCode = 1
134 } else if (statusValue.startsWith("alpha")) {
135 statusCode = 2
136 } else if (statusValue.startsWith("beta")) {
137 statusCode = 3
138 } else if (statusValue.startsWith("rc")) {
139 statusCode = 4
140 } else if (statusValue.startsWith("stable")) {
141 statusCode = 5
142 } else {
143 statusCode = 0
144 }
145
146 libraryVersionCode = statusCode
147 }
148
149 if (map.containsKey("patch")) {
150 libraryVersionCode += Integer.parseInt(map["patch"]) * 10
151 }
152
153 if (map.containsKey("minor")) {
154 libraryVersionCode += (Integer.parseInt(map["minor"]) * 1000)
155 }
156
157 if (map.containsKey("major")) {
158 libraryVersionCode += (Integer.parseInt(map["major"]) * 100000)
159 }
160 } catch (NumberFormatException ignore) {
161 libraryVersionCode = 1
162 }
163 }
164 }
165
166 if (libraryVersionName.isEmpty()) {
167 // Fallback value in case we're unable to read the file.
168 libraryVersionName = "custom_build"
169 }
170
171 if (libraryVersionCode == 0) {
172 libraryVersionCode = 1
173 }
174
175 return [libraryVersionName, libraryVersionCode]
176}
177
178ext.getGodotLibraryVersion = { ->
179 List<String> requiredKeys = ["major", "minor", "patch", "status", "module_config"]
180 return generateGodotLibraryVersion(requiredKeys)
181}
182
183ext.getGodotPublishVersion = { ->
184 List<String> requiredKeys = ["major", "minor", "patch", "status"]
185 String versionName = ""
186 int versionCode = 1
187 (versionName, versionCode) = generateGodotLibraryVersion(requiredKeys)
188 if (!versionName.endsWith("stable")) {
189 versionName += "-SNAPSHOT"
190 }
191 return versionName
192}
193
194final String VALUE_SEPARATOR_REGEX = "\\|"
195
196// get the list of ABIs the project should be exported to
197ext.getExportEnabledABIs = { ->
198 String enabledABIs = project.hasProperty("export_enabled_abis") ? project.property("export_enabled_abis") : ""
199 if (enabledABIs == null || enabledABIs.isEmpty()) {
200 enabledABIs = "armeabi-v7a|arm64-v8a|x86|x86_64|"
201 }
202 Set<String> exportAbiFilter = []
203 for (String abi_name : enabledABIs.split(VALUE_SEPARATOR_REGEX)) {
204 if (!abi_name.trim().isEmpty()){
205 exportAbiFilter.add(abi_name)
206 }
207 }
208 return exportAbiFilter
209}
210
211ext.getExportPath = {
212 String exportPath = project.hasProperty("export_path") ? project.property("export_path") : ""
213 if (exportPath == null || exportPath.isEmpty()) {
214 exportPath = "."
215 }
216 return exportPath
217}
218
219ext.getExportFilename = {
220 String exportFilename = project.hasProperty("export_filename") ? project.property("export_filename") : ""
221 if (exportFilename == null || exportFilename.isEmpty()) {
222 exportFilename = "godot_android"
223 }
224 return exportFilename
225}
226
227ext.getExportEdition = {
228 String exportEdition = project.hasProperty("export_edition") ? project.property("export_edition") : ""
229 if (exportEdition == null || exportEdition.isEmpty()) {
230 exportEdition = "standard"
231 }
232 return exportEdition
233}
234
235ext.getExportBuildType = {
236 String exportBuildType = project.hasProperty("export_build_type") ? project.property("export_build_type") : ""
237 if (exportBuildType == null || exportBuildType.isEmpty()) {
238 exportBuildType = "debug"
239 }
240 return exportBuildType
241}
242
243ext.getExportFormat = {
244 String exportFormat = project.hasProperty("export_format") ? project.property("export_format") : ""
245 if (exportFormat == null || exportFormat.isEmpty()) {
246 exportFormat = "apk"
247 }
248 return exportFormat
249}
250
251/**
252 * Parse the project properties for the 'plugins_maven_repos' property and return the list
253 * of maven repos.
254 */
255ext.getGodotPluginsMavenRepos = { ->
256 Set<String> mavenRepos = []
257
258 // Retrieve the list of maven repos.
259 if (project.hasProperty("plugins_maven_repos")) {
260 String mavenReposProperty = project.property("plugins_maven_repos")
261 if (mavenReposProperty != null && !mavenReposProperty.trim().isEmpty()) {
262 for (String mavenRepoUrl : mavenReposProperty.split(VALUE_SEPARATOR_REGEX)) {
263 mavenRepos += mavenRepoUrl.trim()
264 }
265 }
266 }
267
268 return mavenRepos
269}
270
271/**
272 * Parse the project properties for the 'plugins_remote_binaries' property and return
273 * it for inclusion in the build dependencies.
274 */
275ext.getGodotPluginsRemoteBinaries = { ->
276 Set<String> remoteDeps = []
277
278 // Retrieve the list of remote plugins binaries.
279 if (project.hasProperty("plugins_remote_binaries")) {
280 String remoteDepsList = project.property("plugins_remote_binaries")
281 if (remoteDepsList != null && !remoteDepsList.trim().isEmpty()) {
282 for (String dep: remoteDepsList.split(VALUE_SEPARATOR_REGEX)) {
283 remoteDeps += dep.trim()
284 }
285 }
286 }
287 return remoteDeps
288}
289
290/**
291 * Parse the project properties for the 'plugins_local_binaries' property and return
292 * their binaries for inclusion in the build dependencies.
293 */
294ext.getGodotPluginsLocalBinaries = { ->
295 Set<String> binDeps = []
296
297 // Retrieve the list of local plugins binaries.
298 if (project.hasProperty("plugins_local_binaries")) {
299 String pluginsList = project.property("plugins_local_binaries")
300 if (pluginsList != null && !pluginsList.trim().isEmpty()) {
301 for (String plugin : pluginsList.split(VALUE_SEPARATOR_REGEX)) {
302 binDeps += plugin.trim()
303 }
304 }
305 }
306
307 return binDeps
308}
309
310ext.getDebugKeystoreFile = { ->
311 String keystoreFile = project.hasProperty("debug_keystore_file") ? project.property("debug_keystore_file") : ""
312 if (keystoreFile == null || keystoreFile.isEmpty()) {
313 keystoreFile = "."
314 }
315 return keystoreFile
316}
317
318ext.hasCustomDebugKeystore = { ->
319 File keystoreFile = new File(getDebugKeystoreFile())
320 return keystoreFile.isFile()
321}
322
323ext.getDebugKeystorePassword = { ->
324 String keystorePassword = project.hasProperty("debug_keystore_password") ? project.property("debug_keystore_password") : ""
325 if (keystorePassword == null || keystorePassword.isEmpty()) {
326 keystorePassword = "android"
327 }
328 return keystorePassword
329}
330
331ext.getDebugKeyAlias = { ->
332 String keyAlias = project.hasProperty("debug_keystore_alias") ? project.property("debug_keystore_alias") : ""
333 if (keyAlias == null || keyAlias.isEmpty()) {
334 keyAlias = "androiddebugkey"
335 }
336 return keyAlias
337}
338
339ext.getReleaseKeystoreFile = { ->
340 String keystoreFile = project.hasProperty("release_keystore_file") ? project.property("release_keystore_file") : ""
341 if (keystoreFile == null || keystoreFile.isEmpty()) {
342 keystoreFile = "."
343 }
344 return keystoreFile
345}
346
347ext.getReleaseKeystorePassword = { ->
348 String keystorePassword = project.hasProperty("release_keystore_password") ? project.property("release_keystore_password") : ""
349 return keystorePassword
350}
351
352ext.getReleaseKeyAlias = { ->
353 String keyAlias = project.hasProperty("release_keystore_alias") ? project.property("release_keystore_alias") : ""
354 return keyAlias
355}
356
357ext.isAndroidStudio = { ->
358 return project.hasProperty('android.injected.invoked.from.ide')
359}
360
361ext.shouldZipAlign = { ->
362 String zipAlignFlag = project.hasProperty("perform_zipalign") ? project.property("perform_zipalign") : ""
363 if (zipAlignFlag == null || zipAlignFlag.isEmpty()) {
364 if (isAndroidStudio()) {
365 zipAlignFlag = "true"
366 } else {
367 zipAlignFlag = "false"
368 }
369 }
370 return Boolean.parseBoolean(zipAlignFlag)
371}
372
373ext.shouldSign = { ->
374 String signFlag = project.hasProperty("perform_signing") ? project.property("perform_signing") : ""
375 if (signFlag == null || signFlag.isEmpty()) {
376 if (isAndroidStudio()) {
377 signFlag = "true"
378 } else {
379 signFlag = "false"
380 }
381 }
382 return Boolean.parseBoolean(signFlag)
383}
384
385ext.shouldNotStrip = { ->
386 return isAndroidStudio() || project.hasProperty("doNotStrip")
387}
388
389/**
390 * Whether to use the legacy convention of compressing all .so files in the APK.
391 *
392 * For more background, see:
393 * - https://developer.android.com/build/releases/past-releases/agp-3-6-0-release-notes#extractNativeLibs
394 * - https://stackoverflow.com/a/44704840
395 */
396ext.shouldUseLegacyPackaging = { ->
397 String legacyPackagingFlag = project.hasProperty("compress_native_libraries") ? project.property("compress_native_libraries") : ""
398 if (legacyPackagingFlag != null && !legacyPackagingFlag.isEmpty()) {
399 return Boolean.parseBoolean(legacyPackagingFlag)
400 }
401
402 if (getExportMinSdkVersion() <= 29) {
403 // Use legacy packaging for compatibility with device running api <= 29.
404 // See https://github.com/godotengine/godot/issues/108842 for reference.
405 return true
406 }
407
408 // Default behavior for minSdk > 29.
409 return false
410}
411
412ext.getAddonsDirectory = { ->
413 String addonsDirectory = project.hasProperty("addons_directory") ? project.property("addons_directory") : ""
414 return addonsDirectory
415}
416
417ext.shouldMinify = { ->
418 String minifyFlag = project.hasProperty("enable_minification") ? project.property("enable_minification") : ""
419 if (minifyFlag == null || minifyFlag.isEmpty()) {
420 minifyFlag = "false"
421 }
422 return Boolean.parseBoolean(minifyFlag)
423}