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

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