您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. import groovy.json.JsonSlurper
  2. import org.apache.tools.ant.taskdefs.condition.Os
  3. import org.gradle.util.VersionNumber
  4. // Top-level build file where you can add configuration options common to all
  5. // sub-projects/modules.
  6. buildscript {
  7. repositories {
  8. google()
  9. mavenCentral()
  10. }
  11. dependencies {
  12. classpath 'com.android.tools.build:gradle:7.0.4'
  13. classpath 'com.google.gms:google-services:4.3.10'
  14. classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
  15. }
  16. }
  17. ext {
  18. buildToolsVersion = "31.0.0"
  19. compileSdkVersion = 31
  20. minSdkVersion = 23
  21. targetSdkVersion = 31
  22. supportLibVersion = "28.0.0"
  23. if (System.properties['os.arch'] == "aarch64") {
  24. // For M1 Users we need to use the NDK 24 which added support for aarch64
  25. ndkVersion = "24.0.8215888"
  26. } else if (Os.isFamily(Os.FAMILY_WINDOWS)) {
  27. // For Android Users, we need to use NDK 23, otherwise the build will
  28. // fail due to paths longer than the OS limit
  29. ndkVersion = "23.1.7779620"
  30. } else {
  31. // Otherwise we default to the side-by-side NDK version from AGP.
  32. ndkVersion = "21.4.7075529"
  33. }
  34. // The Maven artifact groupdId of the third-party react-native modules which
  35. // Jitsi Meet SDK for Android depends on and which are not available in
  36. // third-party Maven repositories so we have to deploy to a Maven repository
  37. // of ours.
  38. moduleGroupId = 'com.facebook.react'
  39. // Maven repo where artifacts will be published
  40. mavenRepo = System.env.MVN_REPO ?: ""
  41. mavenUser = System.env.MVN_USER ?: ""
  42. mavenPassword = System.env.MVN_PASSWORD ?: ""
  43. // Libre build
  44. libreBuild = (System.env.LIBRE_BUILD ?: "false").toBoolean()
  45. googleServicesEnabled = project.file('app/google-services.json').exists() && !libreBuild
  46. }
  47. allprojects {
  48. repositories {
  49. // React Native (JS, Obj-C sources, Android binaries) is installed from npm.
  50. maven { url "$rootDir/../node_modules/react-native/android" }
  51. // Android JSC is installed from npm.
  52. maven { url("$rootDir/../node_modules/jsc-android/dist") }
  53. mavenCentral {
  54. // We don't want to fetch react-native from Maven Central as there are
  55. // older versions over there.
  56. content {
  57. excludeGroup "com.facebook.react"
  58. }
  59. }
  60. google()
  61. maven { url 'https://www.jitpack.io' }
  62. }
  63. // Make sure we use the react-native version in node_modules and not the one
  64. // published in jcenter / elsewhere.
  65. configurations.all {
  66. resolutionStrategy {
  67. eachDependency { DependencyResolveDetails details ->
  68. if (details.requested.group == 'com.facebook.react'
  69. && details.requested.name == 'react-native') {
  70. def file = new File("$rootDir/../node_modules/react-native/package.json")
  71. def version = new JsonSlurper().parseText(file.text).version
  72. details.useVersion version
  73. }
  74. }
  75. }
  76. }
  77. // Third-party react-native modules which Jitsi Meet SDK for Android depends
  78. // on and which are not available in third-party Maven repositories need to
  79. // be deployed in a Maven repository of ours.
  80. //
  81. if (project.name.startsWith('react-native-')) {
  82. apply plugin: 'maven-publish'
  83. publishing {
  84. publications {}
  85. repositories {
  86. maven {
  87. url rootProject.ext.mavenRepo
  88. if (!rootProject.ext.mavenRepo.startsWith("file")) {
  89. credentials {
  90. username rootProject.ext.mavenUser
  91. password rootProject.ext.mavenPassword
  92. }
  93. }
  94. }
  95. }
  96. }
  97. }
  98. // Use the number of seconds/10 since Jan 1 2019 as the version qualifier number.
  99. // This will last for the next ~680 years.
  100. // https://stackoverflow.com/a/38643838
  101. def versionQualifierNumber = (int)(((new Date().getTime()/1000) - 1546297200) / 10)
  102. afterEvaluate { project ->
  103. if (project.plugins.hasPlugin('android') || project.plugins.hasPlugin('android-library')) {
  104. project.android {
  105. compileSdkVersion rootProject.ext.compileSdkVersion
  106. buildToolsVersion rootProject.ext.buildToolsVersion
  107. }
  108. }
  109. if (project.name.startsWith('react-native-')) {
  110. def npmManifest = project.file('../package.json')
  111. def json = new JsonSlurper().parseText(npmManifest.text)
  112. // Release every dependency the SDK has with a -jitsi-XXX qualified version. This allows
  113. // us to pin the dependencies and make sure they are always updated, no matter what.
  114. project.version = "${json.version}-jitsi-${versionQualifierNumber}"
  115. task jitsiAndroidSourcesJar(type: Jar) {
  116. classifier = 'sources'
  117. from android.sourceSets.main.java.source
  118. }
  119. publishing.publications {
  120. aarArchive(MavenPublication) {
  121. groupId rootProject.ext.moduleGroupId
  122. artifactId project.name
  123. version project.version
  124. artifact("${project.buildDir}/outputs/aar/${project.name}-release.aar") {
  125. extension "aar"
  126. }
  127. artifact(jitsiAndroidSourcesJar)
  128. pom.withXml {
  129. def pomXml = asNode()
  130. pomXml.appendNode('name', project.name)
  131. pomXml.appendNode('description', json.description)
  132. pomXml.appendNode('url', json.homepage)
  133. if (json.license) {
  134. def license = pomXml.appendNode('licenses').appendNode('license')
  135. license.appendNode('name', json.license)
  136. license.appendNode('distribution', 'repo')
  137. }
  138. def dependencies = pomXml.appendNode('dependencies')
  139. configurations.getByName('releaseCompileClasspath').getResolvedConfiguration().getFirstLevelModuleDependencies().each {
  140. def artifactId = it.moduleName
  141. def version = it.moduleVersion
  142. // React Native signals breaking changes by
  143. // increasing the minor version number. So the
  144. // (third-party) React Native modules we utilize can
  145. // depend not on a specific react-native release but
  146. // a wider range.
  147. if (artifactId == 'react-native') {
  148. def versionNumber = VersionNumber.parse(version)
  149. version = "${versionNumber.major}.${versionNumber.minor}"
  150. }
  151. def dependency = dependencies.appendNode('dependency')
  152. dependency.appendNode('groupId', it.moduleGroup)
  153. dependency.appendNode('artifactId', artifactId)
  154. dependency.appendNode('version', version)
  155. }
  156. }
  157. }
  158. }
  159. }
  160. }
  161. }
  162. // Force the version of the Android build tools we have chosen on all
  163. // subprojects. The forcing was introduced for react-native and the third-party
  164. // modules that we utilize such as react-native-background-timer.
  165. subprojects { subproject ->
  166. afterEvaluate{
  167. if ((subproject.plugins.hasPlugin('android')
  168. || subproject.plugins.hasPlugin('android-library'))
  169. && rootProject.ext.has('buildToolsVersion')) {
  170. android {
  171. buildToolsVersion rootProject.ext.buildToolsVersion
  172. }
  173. }
  174. }
  175. }