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

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