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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. // 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. mavenCentral {
  43. // We don't want to fetch react-native from Maven Central as there are
  44. // older versions over there.
  45. content {
  46. excludeGroup "com.facebook.react"
  47. }
  48. }
  49. google()
  50. maven { url 'https://www.jitpack.io' }
  51. }
  52. // Make sure we use the react-native version in node_modules and not the one
  53. // published in jcenter / elsewhere.
  54. configurations.all {
  55. resolutionStrategy {
  56. eachDependency { DependencyResolveDetails details ->
  57. if (details.requested.group == 'com.facebook.react'
  58. && details.requested.name == 'react-native') {
  59. def file = new File("$rootDir/../node_modules/react-native/package.json")
  60. def version = new JsonSlurper().parseText(file.text).version
  61. details.useVersion version
  62. }
  63. }
  64. }
  65. }
  66. // Third-party react-native modules which Jitsi Meet SDK for Android depends
  67. // on and which are not available in third-party Maven repositories need to
  68. // be deployed in a Maven repository of ours.
  69. //
  70. if (project.name.startsWith('react-native-')) {
  71. apply plugin: 'maven-publish'
  72. publishing {
  73. publications {}
  74. repositories {
  75. maven {
  76. url rootProject.ext.mavenRepo
  77. if (!rootProject.ext.mavenRepo.startsWith("file")) {
  78. credentials {
  79. username rootProject.ext.mavenUser
  80. password rootProject.ext.mavenPassword
  81. }
  82. }
  83. }
  84. }
  85. }
  86. }
  87. // Use the number of seconds/10 since Jan 1 2019 as the version qualifier number.
  88. // This will last for the next ~680 years.
  89. // https://stackoverflow.com/a/38643838
  90. def versionQualifierNumber = (int)(((new Date().getTime()/1000) - 1546297200) / 10)
  91. afterEvaluate { project ->
  92. if (project.plugins.hasPlugin('android') || project.plugins.hasPlugin('android-library')) {
  93. project.android {
  94. compileSdkVersion rootProject.ext.compileSdkVersion
  95. buildToolsVersion rootProject.ext.buildToolsVersion
  96. }
  97. }
  98. if (project.name.startsWith('react-native-')) {
  99. def npmManifest = project.file('../package.json')
  100. def json = new JsonSlurper().parseText(npmManifest.text)
  101. // Release every dependency the SDK has with a -jitsi-XXX qualified version. This allows
  102. // us to pin the dependencies and make sure they are always updated, no matter what.
  103. project.version = "${json.version}-jitsi-${versionQualifierNumber}"
  104. task jitsiAndroidSourcesJar(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(jitsiAndroidSourcesJar)
  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. // Force the version of the Android build tools we have chosen on all
  152. // subprojects. The forcing was introduced for react-native and the third-party
  153. // modules that we utilize such as react-native-background-timer.
  154. subprojects { subproject ->
  155. afterEvaluate{
  156. if ((subproject.plugins.hasPlugin('android')
  157. || subproject.plugins.hasPlugin('android-library'))
  158. && rootProject.ext.has('buildToolsVersion')) {
  159. android {
  160. buildToolsVersion rootProject.ext.buildToolsVersion
  161. }
  162. }
  163. }
  164. }