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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. import groovy.json.JsonSlurper
  2. // Top-level build file where you can add configuration options common to all
  3. // sub-projects/modules.
  4. buildscript {
  5. repositories {
  6. google()
  7. jcenter()
  8. repositories {
  9. maven { url 'https://maven.fabric.io/public' }
  10. }
  11. }
  12. dependencies {
  13. classpath 'com.android.tools.build:gradle:3.2.1'
  14. classpath 'com.google.gms:google-services:4.2.0'
  15. classpath 'io.fabric.tools:gradle:1.27.0'
  16. // NOTE: Do not place your application dependencies here; they belong
  17. // in the individual module build.gradle files.
  18. }
  19. }
  20. allprojects {
  21. repositories {
  22. google()
  23. jcenter()
  24. maven { url "$rootDir/../node_modules/jsc-android/dist" }
  25. // React Native (JS, Obj-C sources, Android binaries) is installed from
  26. // npm.
  27. maven { url "$rootDir/../node_modules/react-native/android" }
  28. }
  29. // Make sure we use the react-native version in node_modules and not the one
  30. // published in jcenter / elsewhere.
  31. configurations.all {
  32. resolutionStrategy {
  33. eachDependency { DependencyResolveDetails details ->
  34. if (details.requested.group == 'com.facebook.react'
  35. && details.requested.name == 'react-native') {
  36. def file = new File("$rootDir/../node_modules/react-native/package.json")
  37. def version = new JsonSlurper().parseText(file.text).version
  38. details.useVersion version
  39. }
  40. if (details.requested.group == 'org.webkit'
  41. && details.requested.name == 'android-jsc') {
  42. def file = new File("$rootDir/../node_modules/jsc-android/package.json")
  43. def version = new JsonSlurper().parseText(file.text).version
  44. details.useVersion "r${version.tokenize('.')[0]}"
  45. }
  46. }
  47. }
  48. }
  49. // Third-party react-native modules which Jitsi Meet SDK for Android depends
  50. // on and which are not available in third-party Maven repositories need to
  51. // be deployed in a Maven repository of ours.
  52. //
  53. if (project.name.startsWith('react-native-')) {
  54. apply plugin: 'maven-publish'
  55. publishing {
  56. publications {}
  57. repositories {
  58. maven { url "file:${rootProject.projectDir}/../../jitsi-maven-repository/releases" }
  59. }
  60. }
  61. }
  62. afterEvaluate { project ->
  63. if (project.name.startsWith('react-native-')) {
  64. def npmManifest = project.file('../package.json')
  65. def json = new JsonSlurper().parseText(npmManifest.text)
  66. // React Native modules have an npm peer dependency on react-native,
  67. // they do not have an npm dependency on it. Further below though we
  68. // choose a react-native version (range) when we represent them as
  69. // Maven artifacts. Effectively, we are forking the projects by not
  70. // complying with the full range of their npm peer dependency and,
  71. // consequently, we should qualify their version.
  72. def versionQualifier = '-jitsi-1'
  73. if ('react-native-background-timer' == project.name)
  74. versionQualifier = '-jitsi-3' // 2.0.0 + react-native 0.57
  75. else if ('react-native-calendar-events' == project.name)
  76. versionQualifier = '-jitsi-2' // 1.6.4 + react-native 0.57
  77. else if ('react-native-fast-image' == project.name)
  78. versionQualifier = '-jitsi-2' // 5.1.1 + react-native 0.57
  79. else if ('react-native-google-signin' == project.name)
  80. versionQualifier = '-jitsi-2' // 1.0.2 + react-native 0.57
  81. else if ('react-native-immersive' == project.name)
  82. versionQualifier = '-jitsi-5' // 2.0.0 + react-native 0.57
  83. else if ('react-native-keep-awake' == project.name)
  84. versionQualifier = '-jitsi-4' // 4.0.0 + react-native 0.57
  85. else if ('react-native-linear-gradient' == project.name)
  86. versionQualifier = '-jitsi-1' // 2.4.0 + react-native 0.57
  87. else if ('react-native-sound' == project.name)
  88. versionQualifier = '-jitsi-2' // 0.10.9 + react-native 0.57
  89. else if ('react-native-vector-icons' == project.name)
  90. versionQualifier = '-jitsi-3' // 6.0.2 + react-native 0.57
  91. else if ('react-native-webrtc' == project.name)
  92. versionQualifier = '-jitsi-9' // 6322a9b5a38ce590cfaea4041072ea87c8dbf558 + react-native 0.57
  93. project.version = "${json.version}${versionQualifier}"
  94. project.android {
  95. compileSdkVersion rootProject.ext.compileSdkVersion
  96. if (rootProject.ext.has('buildToolsVersion')) {
  97. buildToolsVersion rootProject.ext.buildToolsVersion
  98. }
  99. defaultConfig {
  100. minSdkVersion rootProject.ext.minSdkVersion
  101. targetSdkVersion rootProject.ext.targetSdkVersion
  102. }
  103. }
  104. task androidSourcesJar(type: Jar) {
  105. classifier = 'sources'
  106. from android.sourceSets.main.java.source
  107. }
  108. publishing.publications {
  109. aarArchive(MavenPublication) {
  110. groupId rootProject.ext.moduleGroupId
  111. artifactId project.name
  112. version project.version
  113. artifact("${project.buildDir}/outputs/aar/${project.name}-release.aar") {
  114. extension "aar"
  115. }
  116. artifact(androidSourcesJar)
  117. pom.withXml {
  118. def pomXml = asNode()
  119. pomXml.appendNode('name', project.name)
  120. pomXml.appendNode('description', json.description)
  121. pomXml.appendNode('url', json.homepage)
  122. if (json.license) {
  123. def license = pomXml.appendNode('licenses').appendNode('license')
  124. license.appendNode('name', json.license)
  125. license.appendNode('distribution', 'repo')
  126. }
  127. def dependencies = pomXml.appendNode('dependencies')
  128. configurations.getByName('releaseCompileClasspath').getResolvedConfiguration().getFirstLevelModuleDependencies().each {
  129. def artifactId = it.moduleName
  130. def version = it.moduleVersion
  131. // React Native signals breaking changes by
  132. // increasing the minor version number. So the
  133. // (third-party) React Native modules we utilize can
  134. // depend not on a specific react-native release but
  135. // a wider range.
  136. if (artifactId == 'react-native') {
  137. def versionNumber = VersionNumber.parse(version)
  138. version = "${versionNumber.major}.${versionNumber.minor}"
  139. }
  140. def dependency = dependencies.appendNode('dependency')
  141. dependency.appendNode('groupId', it.moduleGroup)
  142. dependency.appendNode('artifactId', artifactId)
  143. dependency.appendNode('version', version)
  144. }
  145. }
  146. }
  147. }
  148. }
  149. }
  150. }
  151. ext {
  152. buildToolsVersion = "28.0.3"
  153. compileSdkVersion = 28
  154. minSdkVersion = 21
  155. targetSdkVersion = 28
  156. supportLibVersion = "28.0.0"
  157. // The Maven artifact groupdId of the third-party react-native modules which
  158. // Jitsi Meet SDK for Android depends on and which are not available in
  159. // third-party Maven repositories so we have to deploy to a Maven repository
  160. // of ours.
  161. moduleGroupId = 'com.facebook.react'
  162. // Glide
  163. excludeAppGlideModule = true
  164. glideVersion = "4.7.1" // keep in sync with react-native-fast-image
  165. }
  166. // If Android SDK is not installed, accept its license so that it
  167. // is automatically downloaded.
  168. afterEvaluate { project ->
  169. // Either the environment variable ANDROID_HOME or the property sdk.dir in
  170. // local.properties identifies where Android SDK is installed.
  171. def androidHome = System.env.ANDROID_HOME
  172. if (!androidHome) {
  173. // ANDROID_HOME is not set. Is sdk.dir set?
  174. def file = file("${project.rootDir}/local.properties")
  175. def props = new Properties()
  176. if (file.canRead()) {
  177. file.withInputStream {
  178. props.load(it)
  179. androidHome = props.'sdk.dir'
  180. }
  181. }
  182. if (!androidHome && (!file.exists() || file.canWrite())) {
  183. // Neither ANDROID_HOME nor sdk.dir is set. Set sdk.dir (because
  184. // environment variables cannot be set).
  185. props.'sdk.dir' = "${project.buildDir}/android-sdk".toString()
  186. file.withOutputStream {
  187. props.store(it, null)
  188. androidHome = props.'sdk.dir'
  189. }
  190. }
  191. }
  192. // If the license is not accepted, accept it so that automatic downloading
  193. // kicks in.
  194. // The license hash can be taken from the accepted licenses, by doing this
  195. // on your local machine the file is
  196. // ${androidHome}/licenses/android-sdk-license
  197. if (androidHome) {
  198. def dir = file("${androidHome}/licenses")
  199. dir.mkdirs()
  200. def file = file("${dir.path}/android-sdk-license")
  201. if (!file.exists()) {
  202. file.withWriter {
  203. def hash = 'd56f5187479451eabf01fb78af6dfcb131a6481e'
  204. it.write(hash, 0, hash.length())
  205. }
  206. }
  207. }
  208. }
  209. // Force the version of the Android build tools we have chosen on all
  210. // subprojects. The forcing was introduced for react-native and the third-party
  211. // modules that we utilize such as react-native-background-timer.
  212. subprojects { subproject ->
  213. afterEvaluate{
  214. if ((subproject.plugins.hasPlugin('android')
  215. || subproject.plugins.hasPlugin('android-library'))
  216. && rootProject.ext.has('buildToolsVersion')) {
  217. android {
  218. buildToolsVersion rootProject.ext.buildToolsVersion
  219. }
  220. }
  221. }
  222. }