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.1KB

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