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.2KB

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