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

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