You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build.gradle 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. buildscript {
  2. repositories {
  3. google()
  4. mavenCentral()
  5. }
  6. dependencies {
  7. classpath 'com.android.tools.build:gradle:3.5.3'
  8. }
  9. }
  10. def isNewArchitectureEnabled() {
  11. return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
  12. }
  13. apply plugin: 'com.android.library'
  14. if (isNewArchitectureEnabled()) {
  15. apply plugin: 'com.facebook.react'
  16. }
  17. def getExtOrDefault(name) {
  18. return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['JitsiMeetReactNative_' + name]
  19. }
  20. def getExtOrIntegerDefault(name) {
  21. return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['JitsiMeetReactNative_' + name]).toInteger()
  22. }
  23. android {
  24. compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
  25. defaultConfig {
  26. minSdkVersion getExtOrIntegerDefault('minSdkVersion')
  27. targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
  28. buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
  29. }
  30. buildTypes {
  31. release {
  32. minifyEnabled false
  33. }
  34. }
  35. lintOptions {
  36. disable 'GradleCompatible'
  37. }
  38. compileOptions {
  39. sourceCompatibility JavaVersion.VERSION_1_8
  40. targetCompatibility JavaVersion.VERSION_1_8
  41. }
  42. }
  43. repositories {
  44. mavenCentral()
  45. google()
  46. def found = false
  47. def defaultDir = null
  48. def androidSourcesName = 'React Native sources'
  49. if (rootProject.ext.has('reactNativeAndroidRoot')) {
  50. defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
  51. } else {
  52. defaultDir = new File(
  53. projectDir,
  54. '/../../../node_modules/react-native/android'
  55. )
  56. }
  57. if (defaultDir.exists()) {
  58. maven {
  59. url defaultDir.toString()
  60. name androidSourcesName
  61. }
  62. logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
  63. found = true
  64. } else {
  65. def parentDir = rootProject.projectDir
  66. 1.upto(5, {
  67. if (found) return true
  68. parentDir = parentDir.parentFile
  69. def androidSourcesDir = new File(
  70. parentDir,
  71. 'node_modules/react-native'
  72. )
  73. def androidPrebuiltBinaryDir = new File(
  74. parentDir,
  75. 'node_modules/react-native/android'
  76. )
  77. if (androidPrebuiltBinaryDir.exists()) {
  78. maven {
  79. url androidPrebuiltBinaryDir.toString()
  80. name androidSourcesName
  81. }
  82. logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
  83. found = true
  84. } else if (androidSourcesDir.exists()) {
  85. maven {
  86. url androidSourcesDir.toString()
  87. name androidSourcesName
  88. }
  89. logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
  90. found = true
  91. }
  92. })
  93. }
  94. if (!found) {
  95. throw new GradleException(
  96. "${project.name}: unable to locate React Native android sources. " +
  97. "Ensure you have you installed React Native as a dependency in your project and try again."
  98. )
  99. }
  100. }
  101. dependencies {
  102. //noinspection GradleDynamicVersion
  103. implementation "com.facebook.react:react-native:+"
  104. implementation 'com.squareup.duktape:duktape-android:1.3.0'
  105. implementation 'com.dropbox.core:dropbox-core-sdk:4.0.1'
  106. implementation 'com.jakewharton.timber:timber:4.7.1'
  107. // From node_modules
  108. }
  109. if (isNewArchitectureEnabled()) {
  110. react {
  111. jsRootDir = file("../")
  112. libraryName = "JitsiMeetReactNative"
  113. codegenJavaPackageName = "org.jitsi.meet.sdk"
  114. }
  115. }
  116. // Copy sounds to assets directory
  117. android.libraryVariants.all { def variant ->
  118. def mergeAssetsTask = variant.mergeAssetsProvider.get()
  119. def mergeResourcesTask = variant.mergeResourcesProvider.get()
  120. mergeAssetsTask.doLast {
  121. def assetsDir = mergeAssetsTask.outputDir.get()
  122. def soundsDir = "${projectDir}/../sounds"
  123. copy {
  124. from("${soundsDir}")
  125. include("*.wav")
  126. include("*.mp3")
  127. into("${assetsDir}/sounds")
  128. }
  129. }
  130. }