build.gradle 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. // Gradle build config for Godot Engine's Android port.
  2. //
  3. // Do not remove/modify comments ending with BEGIN/END, they are used to inject
  4. // addon-specific configuration.
  5. apply from: 'config.gradle'
  6. buildscript {
  7. apply from: 'config.gradle'
  8. repositories {
  9. google()
  10. mavenCentral()
  11. //CHUNK_BUILDSCRIPT_REPOSITORIES_BEGIN
  12. //CHUNK_BUILDSCRIPT_REPOSITORIES_END
  13. }
  14. dependencies {
  15. classpath libraries.androidGradlePlugin
  16. classpath libraries.kotlinGradlePlugin
  17. //CHUNK_BUILDSCRIPT_DEPENDENCIES_BEGIN
  18. //CHUNK_BUILDSCRIPT_DEPENDENCIES_END
  19. }
  20. }
  21. apply plugin: 'com.android.application'
  22. allprojects {
  23. repositories {
  24. google()
  25. mavenCentral()
  26. //CHUNK_ALLPROJECTS_REPOSITORIES_BEGIN
  27. //CHUNK_ALLPROJECTS_REPOSITORIES_END
  28. // Godot user plugins custom maven repos
  29. String[] mavenRepos = getGodotPluginsMavenRepos()
  30. if (mavenRepos != null && mavenRepos.size() > 0) {
  31. for (String repoUrl : mavenRepos) {
  32. maven {
  33. url repoUrl
  34. }
  35. }
  36. }
  37. }
  38. }
  39. dependencies {
  40. implementation libraries.kotlinStdLib
  41. implementation libraries.androidxFragment
  42. if (rootProject.findProject(":lib")) {
  43. implementation project(":lib")
  44. } else if (rootProject.findProject(":godot:lib")) {
  45. implementation project(":godot:lib")
  46. } else {
  47. // Custom build mode. In this scenario this project is the only one around and the Godot
  48. // library is available through the pre-generated godot-lib.*.aar android archive files.
  49. debugImplementation fileTree(dir: 'libs/debug', include: ['*.jar', '*.aar'])
  50. releaseImplementation fileTree(dir: 'libs/release', include: ['*.jar', '*.aar'])
  51. }
  52. // Godot user plugins remote dependencies
  53. String[] remoteDeps = getGodotPluginsRemoteBinaries()
  54. if (remoteDeps != null && remoteDeps.size() > 0) {
  55. for (String dep : remoteDeps) {
  56. implementation dep
  57. }
  58. }
  59. // Godot user plugins local dependencies
  60. String[] pluginsBinaries = getGodotPluginsLocalBinaries()
  61. if (pluginsBinaries != null && pluginsBinaries.size() > 0) {
  62. implementation files(pluginsBinaries)
  63. }
  64. //CHUNK_DEPENDENCIES_BEGIN
  65. //CHUNK_DEPENDENCIES_END
  66. }
  67. android {
  68. compileSdkVersion versions.compileSdk
  69. buildToolsVersion versions.buildTools
  70. compileOptions {
  71. sourceCompatibility versions.javaVersion
  72. targetCompatibility versions.javaVersion
  73. }
  74. assetPacks = [":assetPacks:installTime"]
  75. defaultConfig {
  76. // The default ignore pattern for the 'assets' directory includes hidden files and directories which are used by Godot projects.
  77. aaptOptions {
  78. ignoreAssetsPattern "!.svn:!.git:!.gitignore:!.ds_store:!*.scc:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"
  79. }
  80. ndk {
  81. String[] export_abi_list = getExportEnabledABIs()
  82. abiFilters export_abi_list
  83. }
  84. manifestPlaceholders = [godotEditorVersion: getGodotEditorVersion()]
  85. // Feel free to modify the application id to your own.
  86. applicationId getExportPackageName()
  87. versionCode getExportVersionCode()
  88. versionName getExportVersionName()
  89. minSdkVersion getExportMinSdkVersion()
  90. targetSdkVersion getExportTargetSdkVersion()
  91. //CHUNK_ANDROID_DEFAULTCONFIG_BEGIN
  92. //CHUNK_ANDROID_DEFAULTCONFIG_END
  93. }
  94. lintOptions {
  95. abortOnError false
  96. disable 'MissingTranslation', 'UnusedResources'
  97. }
  98. ndkVersion versions.ndkVersion
  99. packagingOptions {
  100. exclude 'META-INF/LICENSE'
  101. exclude 'META-INF/NOTICE'
  102. // 'doNotStrip' is enabled for development within Android Studio
  103. if (shouldNotStrip()) {
  104. doNotStrip '**/*.so'
  105. }
  106. }
  107. signingConfigs {
  108. debug {
  109. if (hasCustomDebugKeystore()) {
  110. storeFile new File(getDebugKeystoreFile())
  111. storePassword getDebugKeystorePassword()
  112. keyAlias getDebugKeyAlias()
  113. keyPassword getDebugKeystorePassword()
  114. }
  115. }
  116. release {
  117. File keystoreFile = new File(getReleaseKeystoreFile())
  118. if (keystoreFile.isFile()) {
  119. storeFile keystoreFile
  120. storePassword getReleaseKeystorePassword()
  121. keyAlias getReleaseKeyAlias()
  122. keyPassword getReleaseKeystorePassword()
  123. }
  124. }
  125. }
  126. buildTypes {
  127. debug {
  128. // Signing and zip-aligning are skipped for prebuilt builds, but
  129. // performed for custom builds.
  130. zipAlignEnabled shouldZipAlign()
  131. if (shouldSign()) {
  132. signingConfig signingConfigs.debug
  133. } else {
  134. signingConfig null
  135. }
  136. }
  137. release {
  138. // Signing and zip-aligning are skipped for prebuilt builds, but
  139. // performed for custom builds.
  140. zipAlignEnabled shouldZipAlign()
  141. if (shouldSign()) {
  142. signingConfig signingConfigs.release
  143. } else {
  144. signingConfig null
  145. }
  146. }
  147. }
  148. sourceSets {
  149. main {
  150. manifest.srcFile 'AndroidManifest.xml'
  151. java.srcDirs = [
  152. 'src'
  153. //DIR_SRC_BEGIN
  154. //DIR_SRC_END
  155. ]
  156. res.srcDirs = [
  157. 'res'
  158. //DIR_RES_BEGIN
  159. //DIR_RES_END
  160. ]
  161. aidl.srcDirs = [
  162. 'aidl'
  163. //DIR_AIDL_BEGIN
  164. //DIR_AIDL_END
  165. ]
  166. assets.srcDirs = [
  167. 'assets'
  168. //DIR_ASSETS_BEGIN
  169. //DIR_ASSETS_END
  170. ]
  171. }
  172. debug.jniLibs.srcDirs = [
  173. 'libs/debug'
  174. //DIR_JNI_DEBUG_BEGIN
  175. //DIR_JNI_DEBUG_END
  176. ]
  177. release.jniLibs.srcDirs = [
  178. 'libs/release'
  179. //DIR_JNI_RELEASE_BEGIN
  180. //DIR_JNI_RELEASE_END
  181. ]
  182. }
  183. applicationVariants.all { variant ->
  184. variant.outputs.all { output ->
  185. output.outputFileName = "android_${variant.name}.apk"
  186. }
  187. }
  188. }
  189. task copyAndRenameDebugApk(type: Copy) {
  190. from "$buildDir/outputs/apk/debug/android_debug.apk"
  191. into getExportPath()
  192. rename "android_debug.apk", getExportFilename()
  193. }
  194. task copyAndRenameReleaseApk(type: Copy) {
  195. from "$buildDir/outputs/apk/release/android_release.apk"
  196. into getExportPath()
  197. rename "android_release.apk", getExportFilename()
  198. }
  199. task copyAndRenameDebugAab(type: Copy) {
  200. from "$buildDir/outputs/bundle/debug/build-debug.aab"
  201. into getExportPath()
  202. rename "build-debug.aab", getExportFilename()
  203. }
  204. task copyAndRenameReleaseAab(type: Copy) {
  205. from "$buildDir/outputs/bundle/release/build-release.aab"
  206. into getExportPath()
  207. rename "build-release.aab", getExportFilename()
  208. }
  209. //CHUNK_GLOBAL_BEGIN
  210. //CHUNK_GLOBAL_END