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

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