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

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