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 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. apply plugin: 'com.android.library'
  2. apply plugin: 'maven-publish'
  3. android {
  4. compileSdkVersion rootProject.ext.compileSdkVersion
  5. ndkVersion rootProject.ext.ndkVersion
  6. defaultConfig {
  7. minSdkVersion rootProject.ext.minSdkVersion
  8. targetSdkVersion rootProject.ext.targetSdkVersion
  9. }
  10. buildTypes {
  11. debug {
  12. buildConfigField "boolean", "LIBRE_BUILD", "${rootProject.ext.libreBuild}"
  13. buildConfigField "boolean", "GOOGLE_SERVICES_ENABLED", "${rootProject.ext.googleServicesEnabled}"
  14. }
  15. release {
  16. minifyEnabled false
  17. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  18. buildConfigField "boolean", "LIBRE_BUILD", "${rootProject.ext.libreBuild}"
  19. buildConfigField "boolean", "GOOGLE_SERVICES_ENABLED", "${rootProject.ext.googleServicesEnabled}"
  20. }
  21. }
  22. sourceSets {
  23. main {
  24. java {
  25. exclude "test/"
  26. }
  27. }
  28. }
  29. }
  30. dependencies {
  31. implementation fileTree(dir: 'libs', include: ['*.jar'])
  32. // https://github.com/facebook/react-native/issues/31572
  33. // We can update past 1.4.0 on RN 0.68
  34. implementation ('androidx.appcompat:appcompat:1.3.1') {
  35. version {
  36. strictly '1.3.1'
  37. }
  38. }
  39. implementation 'androidx.fragment:fragment:1.4.0'
  40. implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
  41. implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
  42. //noinspection GradleDynamicVersion
  43. api 'com.facebook.react:react-native:+'
  44. //noinspection GradleDynamicVersion
  45. implementation 'org.webkit:android-jsc:+'
  46. implementation 'com.dropbox.core:dropbox-core-sdk:4.0.1'
  47. implementation 'com.jakewharton.timber:timber:4.7.1'
  48. implementation 'com.squareup.duktape:duktape-android:1.3.0'
  49. implementation 'com.google.code.gson:gson:2.8.6'
  50. implementation "androidx.startup:startup-runtime:1.1.0"
  51. if (rootProject.ext.libreBuild) {
  52. implementation(project(':react-native-device-info')) {
  53. exclude group: 'com.google.firebase'
  54. exclude group: 'com.google.android.gms'
  55. exclude group: 'com.android.installreferrer'
  56. }
  57. } else {
  58. implementation project(':react-native-amplitude')
  59. implementation project(':react-native-device-info')
  60. implementation(project(":react-native-google-signin")) {
  61. exclude group: 'com.google.android.gms'
  62. exclude group: 'androidx'
  63. }
  64. }
  65. implementation project(':react-native-async-storage')
  66. implementation project(':react-native-background-timer')
  67. implementation project(':react-native-calendar-events')
  68. implementation project(':react-native-community_clipboard')
  69. implementation project(':react-native-community_netinfo')
  70. implementation project(':react-native-default-preference')
  71. implementation project(':react-native-gesture-handler')
  72. implementation project(':react-native-get-random-values')
  73. implementation project(':react-native-immersive')
  74. implementation project(':react-native-keep-awake')
  75. implementation project(':react-native-masked-view_masked-view')
  76. implementation project(':react-native-pager-view')
  77. implementation project(':react-native-performance')
  78. implementation project(':react-native-reanimated')
  79. implementation project(':react-native-safe-area-context')
  80. implementation project(':react-native-screens')
  81. implementation project(':react-native-slider')
  82. implementation project(':react-native-sound')
  83. implementation project(':react-native-splash-screen')
  84. implementation project(':react-native-svg')
  85. implementation project(':react-native-video')
  86. implementation project(':react-native-webrtc')
  87. implementation project(':react-native-webview')
  88. testImplementation 'junit:junit:4.12'
  89. }
  90. // Here we bundle all assets, resources and React files. We cannot use the
  91. // react.gradle file provided by react-native because it's designed to be used
  92. // in an application (it taps into applicationVariants, but the SDK is a library
  93. // so we need libraryVariants instead).
  94. android.libraryVariants.all { def variant ->
  95. // Create variant and target names
  96. def targetName = variant.name.capitalize()
  97. def targetPath = variant.dirName
  98. // React js bundle directories
  99. def jsBundleDir = file("$buildDir/generated/assets/react/${targetPath}")
  100. def resourcesDir = file("$buildDir/generated/res/react/${targetPath}")
  101. def jsBundleFile = file("$jsBundleDir/index.android.bundle")
  102. def currentBundleTask = tasks.create(
  103. name: "bundle${targetName}JsAndAssets",
  104. type: Exec) {
  105. group = "react"
  106. description = "bundle JS and assets for ${targetName}."
  107. // Create dirs if they are not there (e.g. the "clean" task just ran)
  108. doFirst {
  109. jsBundleDir.deleteDir()
  110. jsBundleDir.mkdirs()
  111. resourcesDir.deleteDir()
  112. resourcesDir.mkdirs()
  113. }
  114. // Set up inputs and outputs so gradle can cache the result
  115. def reactRoot = file("${projectDir}/../../")
  116. inputs.files fileTree(dir: reactRoot, excludes: ["android/**", "ios/**"])
  117. outputs.dir jsBundleDir
  118. outputs.dir resourcesDir
  119. // Set up the call to the react-native cli
  120. workingDir reactRoot
  121. // Set up dev mode
  122. def devEnabled = !targetName.toLowerCase().contains("release")
  123. // Run the bundler
  124. commandLine(
  125. "node",
  126. "node_modules/react-native/local-cli/cli.js",
  127. "bundle",
  128. "--platform", "android",
  129. "--dev", "${devEnabled}",
  130. "--reset-cache",
  131. "--entry-file", "index.android.js",
  132. "--bundle-output", jsBundleFile,
  133. "--assets-dest", resourcesDir)
  134. // Disable bundling on dev builds
  135. enabled !devEnabled
  136. }
  137. currentBundleTask.ext.generatedResFolders = files(resourcesDir).builtBy(currentBundleTask)
  138. currentBundleTask.ext.generatedAssetsFolders = files(jsBundleDir).builtBy(currentBundleTask)
  139. variant.registerGeneratedResFolders(currentBundleTask.generatedResFolders)
  140. def mergeAssetsTask = variant.mergeAssetsProvider.get()
  141. def mergeResourcesTask = variant.mergeResourcesProvider.get()
  142. mergeAssetsTask.dependsOn(currentBundleTask)
  143. mergeResourcesTask.dependsOn(currentBundleTask)
  144. mergeAssetsTask.doLast {
  145. def assetsDir = mergeAssetsTask.outputDir.get()
  146. // Bundle sounds
  147. //
  148. copy {
  149. from("${projectDir}/../../sounds")
  150. include("*.wav")
  151. include("*.mp3")
  152. into("${assetsDir}/sounds")
  153. }
  154. // Copy React assets
  155. //
  156. if (currentBundleTask.enabled) {
  157. copy {
  158. from(jsBundleFile)
  159. into(assetsDir)
  160. }
  161. }
  162. }
  163. mergeResourcesTask.doLast {
  164. // Copy React resources
  165. //
  166. if (currentBundleTask.enabled) {
  167. copy {
  168. from(resourcesDir)
  169. into(mergeResourcesTask.outputDir.get())
  170. }
  171. }
  172. }
  173. }
  174. publishing {
  175. publications {
  176. aarArchive(MavenPublication) {
  177. groupId 'org.jitsi.react'
  178. artifactId 'jitsi-meet-sdk'
  179. version System.env.OVERRIDE_SDK_VERSION ?: project.sdkVersion
  180. artifact("${project.buildDir}/outputs/aar/${project.name}-release.aar") {
  181. extension "aar"
  182. }
  183. pom.withXml {
  184. def pomXml = asNode()
  185. pomXml.appendNode('name', 'jitsi-meet-sdk')
  186. pomXml.appendNode('description', 'Jitsi Meet SDK for Android')
  187. def dependencies = pomXml.appendNode('dependencies')
  188. configurations.getByName('releaseCompileClasspath').getResolvedConfiguration().getFirstLevelModuleDependencies().each {
  189. // The (third-party) React Native modules that we depend on
  190. // are in source code form and do not have groupId. That is
  191. // why we have a dedicated groupId for them. But the other
  192. // dependencies come through Maven and, consequently, have
  193. // groupId.
  194. def groupId = it.moduleGroup
  195. def artifactId = it.moduleName
  196. if (artifactId.startsWith('react-native-')) {
  197. groupId = rootProject.ext.moduleGroupId
  198. }
  199. def dependency = dependencies.appendNode('dependency')
  200. dependency.appendNode('groupId', groupId)
  201. dependency.appendNode('artifactId', artifactId)
  202. dependency.appendNode('version', it.moduleVersion)
  203. }
  204. }
  205. }
  206. }
  207. repositories {
  208. maven {
  209. url rootProject.ext.mavenRepo
  210. if (!rootProject.ext.mavenRepo.startsWith("file")) {
  211. credentials {
  212. username rootProject.ext.mavenUser
  213. password rootProject.ext.mavenPassword
  214. }
  215. }
  216. }
  217. }
  218. }