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

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