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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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:7.4.2'
  12. classpath 'com.google.gms:google-services:4.4.0'
  13. classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'
  14. }
  15. }
  16. ext {
  17. kotlinVersion = "1.9.24"
  18. buildToolsVersion = "34.0.0"
  19. compileSdkVersion = 34
  20. minSdkVersion = 26
  21. targetSdkVersion = 34
  22. supportLibVersion = "28.0.0"
  23. ndkVersion = "26.1.10909125"
  24. // The Maven artifact groupId of the third-party react-native modules which
  25. // Jitsi Meet SDK for Android depends on and which are not available in
  26. // third-party Maven repositories so we have to deploy to a Maven repository
  27. // of ours.
  28. moduleGroupId = 'com.facebook.react'
  29. // Maven repo where artifacts will be published
  30. mavenRepo = System.env.MVN_REPO ?: ""
  31. mavenUser = System.env.MVN_USER ?: ""
  32. mavenPassword = System.env.MVN_PASSWORD ?: ""
  33. // Libre build
  34. libreBuild = (System.env.LIBRE_BUILD ?: "false").toBoolean()
  35. googleServicesEnabled = project.file('app/google-services.json').exists() && !libreBuild
  36. //React Native and Hermes Version
  37. rnVersion = "0.75.5"
  38. }
  39. allprojects {
  40. repositories {
  41. mavenCentral()
  42. google()
  43. maven { url 'https://www.jitpack.io' }
  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. if (details.requested.name == 'react-native') {
  52. details.useTarget "com.facebook.react:react-android:$rnVersion"
  53. }
  54. if (details.requested.name == 'react-android') {
  55. details.useVersion rootProject.ext.rnVersion
  56. }
  57. }
  58. }
  59. }
  60. }
  61. // Due to a dependency conflict between React Native and the Fresco library used by GiphySDK,
  62. // GIFs appear as static images instead of animating
  63. // https://github.com/Giphy/giphy-react-native-sdk/commit/7fe466ed6fddfaec95f9cbc959d33bd75ad8f900
  64. configurations.configureEach {
  65. resolutionStrategy {
  66. forcedModules = [
  67. 'com.facebook.fresco:fresco:3.2.0',
  68. 'com.facebook.fresco:animated-gif:3.2.0',
  69. 'com.facebook.fresco:animated-base:3.2.0',
  70. 'com.facebook.fresco:animated-drawable:3.2.0',
  71. 'com.facebook.fresco:animated-webp:3.2.0',
  72. 'com.facebook.fresco:webpsupport:3.2.0',
  73. 'com.facebook.fresco:imagepipeline-okhttp3:3.2.0',
  74. 'com.facebook.fresco:middleware:3.2.0',
  75. 'com.facebook.fresco:nativeimagetranscoder:3.2.0'
  76. ]
  77. }
  78. }
  79. // Third-party react-native modules which Jitsi Meet SDK for Android depends
  80. // on and which are not available in third-party Maven repositories need to
  81. // be deployed in a Maven repository of ours.
  82. if (project.name.startsWith('react-native-')) {
  83. apply plugin: 'maven-publish'
  84. publishing {
  85. publications {}
  86. repositories {
  87. maven {
  88. url rootProject.ext.mavenRepo
  89. if (!rootProject.ext.mavenRepo.startsWith("file")) {
  90. credentials {
  91. username rootProject.ext.mavenUser
  92. password rootProject.ext.mavenPassword
  93. }
  94. }
  95. }
  96. }
  97. }
  98. }
  99. // Use the number of seconds/10 since Jan 1 2019 as the version qualifier number.
  100. // This will last for the next ~680 years.
  101. // https://stackoverflow.com/a/38643838
  102. def versionQualifierNumber = (int)(((new Date().getTime()/1000) - 1546297200) / 10)
  103. afterEvaluate { project ->
  104. if (project.plugins.hasPlugin('android') || project.plugins.hasPlugin('android-library')) {
  105. project.android {
  106. compileSdkVersion rootProject.ext.compileSdkVersion
  107. buildToolsVersion rootProject.ext.buildToolsVersion
  108. }
  109. }
  110. if (project.name.startsWith('react-native-')) {
  111. def npmManifest = project.file('../package.json')
  112. def json = new JsonSlurper().parseText(npmManifest.text)
  113. // Release every dependency the SDK has with a -jitsi-XXX qualified version. This allows
  114. // us to pin the dependencies and make sure they are always updated, no matter what.
  115. project.version = "${json.version}-jitsi-${versionQualifierNumber}"
  116. task jitsiAndroidSourcesJar(type: Jar) {
  117. classifier = 'sources'
  118. from android.sourceSets.main.java.source
  119. }
  120. publishing.publications {
  121. aarArchive(MavenPublication) {
  122. groupId rootProject.ext.moduleGroupId
  123. artifactId project.name
  124. version project.version
  125. artifact("${project.buildDir}/outputs/aar/${project.name}-release.aar") {
  126. extension "aar"
  127. }
  128. artifact(jitsiAndroidSourcesJar)
  129. pom.withXml {
  130. def pomXml = asNode()
  131. pomXml.appendNode('name', project.name)
  132. pomXml.appendNode('description', json.description)
  133. pomXml.appendNode('url', json.homepage)
  134. if (json.license) {
  135. def license = pomXml.appendNode('licenses').appendNode('license')
  136. license.appendNode('name', json.license)
  137. license.appendNode('distribution', 'repo')
  138. }
  139. def dependencies = pomXml.appendNode('dependencies')
  140. configurations.getByName('releaseCompileClasspath').getResolvedConfiguration().getFirstLevelModuleDependencies().each {
  141. def artifactId = it.moduleName
  142. def version = it.moduleVersion
  143. // React Native signals breaking changes by
  144. // increasing the minor version number. So the
  145. // (third-party) React Native modules we utilize can
  146. // depend not on a specific react-native release but
  147. // a wider range.
  148. if (artifactId == 'react-native') {
  149. def versionNumber = VersionNumber.parse(version)
  150. version = "${versionNumber.major}.${versionNumber.minor}"
  151. }
  152. def dependency = dependencies.appendNode('dependency')
  153. dependency.appendNode('groupId', it.moduleGroup)
  154. dependency.appendNode('artifactId', artifactId)
  155. dependency.appendNode('version', version)
  156. }
  157. }
  158. }
  159. }
  160. }
  161. }
  162. }
  163. // Force the version of the Android build tools we have chosen on all
  164. // subprojects. The forcing was introduced for react-native and the third-party
  165. // modules that we utilize such as react-native-background-timer.
  166. subprojects { subproject ->
  167. afterEvaluate{
  168. if ((subproject.plugins.hasPlugin('android')
  169. || subproject.plugins.hasPlugin('android-library'))
  170. && rootProject.ext.has('buildToolsVersion')) {
  171. android {
  172. buildToolsVersion rootProject.ext.buildToolsVersion
  173. }
  174. }
  175. }
  176. }