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

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