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

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