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

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