您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

build.gradle 8.1KB

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