build.gradle 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. apply plugin: 'com.android.library'
  2. apply plugin: 'kotlin-android'
  3. dependencies {
  4. implementation libraries.supportCoreUtils
  5. implementation libraries.kotlinStdLib
  6. implementation libraries.v4Support
  7. }
  8. def pathToRootDir = "../../../../"
  9. android {
  10. compileSdkVersion versions.compileSdk
  11. buildToolsVersion versions.buildTools
  12. useLibrary 'org.apache.http.legacy'
  13. defaultConfig {
  14. minSdkVersion versions.minSdk
  15. targetSdkVersion versions.targetSdk
  16. }
  17. lintOptions {
  18. abortOnError false
  19. disable 'MissingTranslation', 'UnusedResources'
  20. }
  21. packagingOptions {
  22. exclude 'META-INF/LICENSE'
  23. exclude 'META-INF/NOTICE'
  24. doNotStrip '**/*.so'
  25. }
  26. sourceSets {
  27. main {
  28. manifest.srcFile 'AndroidManifest.xml'
  29. java.srcDirs = ['src']
  30. res.srcDirs = ['res']
  31. aidl.srcDirs = ['aidl']
  32. assets.srcDirs = ['assets']
  33. }
  34. debug.jniLibs.srcDirs = ['libs/debug']
  35. release.jniLibs.srcDirs = ['libs/release']
  36. }
  37. libraryVariants.all { variant ->
  38. variant.outputs.all { output ->
  39. output.outputFileName = "godot-lib.${variant.name}.aar"
  40. }
  41. def buildType = variant.buildType.name.capitalize()
  42. def taskPrefix = ""
  43. if (project.path != ":") {
  44. taskPrefix = project.path + ":"
  45. }
  46. // Disable the externalNativeBuild* task as it would cause build failures since the cmake build
  47. // files is only setup for editing support.
  48. gradle.startParameter.excludedTaskNames += taskPrefix + "externalNativeBuild" + buildType
  49. def releaseTarget = buildType.toLowerCase()
  50. if (releaseTarget == null || releaseTarget == "") {
  51. throw new GradleException("Invalid build type: " + buildType)
  52. }
  53. if (!supportedAbis.contains(defaultAbi)) {
  54. throw new GradleException("Invalid default abi: " + defaultAbi)
  55. }
  56. // Creating gradle task to generate the native libraries for the default abi.
  57. def taskName = getSconsTaskName(buildType)
  58. tasks.create(name: taskName, type: Exec) {
  59. executable "scons" + sconsExt
  60. args "--directory=${pathToRootDir}", "platform=android", "target=${releaseTarget}", "android_arch=${defaultAbi}", "-j" + Runtime.runtime.availableProcessors()
  61. }
  62. // Schedule the tasks so the generated libs are present before the aar file is packaged.
  63. tasks["merge${buildType}JniLibFolders"].dependsOn taskName
  64. }
  65. externalNativeBuild {
  66. cmake {
  67. path "CMakeLists.txt"
  68. }
  69. }
  70. }