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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. }
  9. dependencies {
  10. classpath 'com.android.tools.build:gradle:4.0.1'
  11. classpath 'com.google.gms:google-services:4.3.3'
  12. classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
  13. }
  14. }
  15. ext {
  16. buildToolsVersion = "29.0.3"
  17. compileSdkVersion = 29
  18. minSdkVersion = 23
  19. targetSdkVersion = 29
  20. supportLibVersion = "28.0.0"
  21. // The Maven artifact groupdId of the third-party react-native modules which
  22. // Jitsi Meet SDK for Android depends on and which are not available in
  23. // third-party Maven repositories so we have to deploy to a Maven repository
  24. // of ours.
  25. moduleGroupId = 'com.facebook.react'
  26. // Maven repo where artifacts will be published
  27. mavenRepo = System.env.MVN_REPO ?: ""
  28. mavenUser = System.env.MVN_USER ?: ""
  29. mavenPassword = System.env.MVN_PASSWORD ?: ""
  30. // Libre build
  31. libreBuild = (System.env.LIBRE_BUILD ?: "false").toBoolean()
  32. googleServicesEnabled = project.file('app/google-services.json').exists() && !libreBuild
  33. }
  34. allprojects {
  35. repositories {
  36. google()
  37. jcenter()
  38. // React Native (JS, Obj-C sources, Android binaries) is installed from npm.
  39. maven { url "$rootDir/../node_modules/react-native/android" }
  40. // Android JSC is installed from npm.
  41. maven { url("$rootDir/../node_modules/jsc-android/dist") }
  42. }
  43. // Make sure we use the react-native version in node_modules and not the one
  44. // published in jcenter / elsewhere.
  45. configurations.all {
  46. resolutionStrategy {
  47. eachDependency { DependencyResolveDetails details ->
  48. if (details.requested.group == 'com.facebook.react'
  49. && details.requested.name == 'react-native') {
  50. def file = new File("$rootDir/../node_modules/react-native/package.json")
  51. def version = new JsonSlurper().parseText(file.text).version
  52. details.useVersion version
  53. }
  54. }
  55. }
  56. }
  57. // Third-party react-native modules which Jitsi Meet SDK for Android depends
  58. // on and which are not available in third-party Maven repositories need to
  59. // be deployed in a Maven repository of ours.
  60. //
  61. if (project.name.startsWith('react-native-')) {
  62. apply plugin: 'maven-publish'
  63. publishing {
  64. publications {}
  65. repositories {
  66. maven {
  67. url rootProject.ext.mavenRepo
  68. if (!rootProject.ext.mavenRepo.startsWith("file")) {
  69. credentials {
  70. username rootProject.ext.mavenUser
  71. password rootProject.ext.mavenPassword
  72. }
  73. }
  74. }
  75. }
  76. }
  77. }
  78. // Use the number of seconds/10 since Jan 1 2019 as the version qualifier number.
  79. // This will last for the next ~680 years.
  80. // https://stackoverflow.com/a/38643838
  81. def versionQualifierNumber = (int)(((new Date().getTime()/1000) - 1546297200) / 10)
  82. afterEvaluate { project ->
  83. if (project.plugins.hasPlugin('android') || project.plugins.hasPlugin('android-library')) {
  84. project.android {
  85. compileSdkVersion rootProject.ext.compileSdkVersion
  86. buildToolsVersion rootProject.ext.buildToolsVersion
  87. }
  88. }
  89. if (project.name.startsWith('react-native-')) {
  90. def npmManifest = project.file('../package.json')
  91. def json = new JsonSlurper().parseText(npmManifest.text)
  92. // Release every dependency the SDK has with a -jitsi-XXX qualified version. This allows
  93. // us to pin the dependencies and make sure they are always updated, no matter what.
  94. project.version = "${json.version}-jitsi-${versionQualifierNumber}"
  95. task androidSourcesJar(type: Jar) {
  96. classifier = 'sources'
  97. from android.sourceSets.main.java.source
  98. }
  99. publishing.publications {
  100. aarArchive(MavenPublication) {
  101. groupId rootProject.ext.moduleGroupId
  102. artifactId project.name
  103. version project.version
  104. artifact("${project.buildDir}/outputs/aar/${project.name}-release.aar") {
  105. extension "aar"
  106. }
  107. artifact(androidSourcesJar)
  108. pom.withXml {
  109. def pomXml = asNode()
  110. pomXml.appendNode('name', project.name)
  111. pomXml.appendNode('description', json.description)
  112. pomXml.appendNode('url', json.homepage)
  113. if (json.license) {
  114. def license = pomXml.appendNode('licenses').appendNode('license')
  115. license.appendNode('name', json.license)
  116. license.appendNode('distribution', 'repo')
  117. }
  118. def dependencies = pomXml.appendNode('dependencies')
  119. configurations.getByName('releaseCompileClasspath').getResolvedConfiguration().getFirstLevelModuleDependencies().each {
  120. def artifactId = it.moduleName
  121. def version = it.moduleVersion
  122. // React Native signals breaking changes by
  123. // increasing the minor version number. So the
  124. // (third-party) React Native modules we utilize can
  125. // depend not on a specific react-native release but
  126. // a wider range.
  127. if (artifactId == 'react-native') {
  128. def versionNumber = VersionNumber.parse(version)
  129. version = "${versionNumber.major}.${versionNumber.minor}"
  130. }
  131. def dependency = dependencies.appendNode('dependency')
  132. dependency.appendNode('groupId', it.moduleGroup)
  133. dependency.appendNode('artifactId', artifactId)
  134. dependency.appendNode('version', version)
  135. }
  136. }
  137. }
  138. }
  139. }
  140. }
  141. }
  142. // Force the version of the Android build tools we have chosen on all
  143. // subprojects. The forcing was introduced for react-native and the third-party
  144. // modules that we utilize such as react-native-background-timer.
  145. subprojects { subproject ->
  146. afterEvaluate{
  147. if ((subproject.plugins.hasPlugin('android')
  148. || subproject.plugins.hasPlugin('android-library'))
  149. && rootProject.ext.has('buildToolsVersion')) {
  150. android {
  151. buildToolsVersion rootProject.ext.buildToolsVersion
  152. }
  153. }
  154. }
  155. }