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

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