build.gradle 6.4 KB

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