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

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