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

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