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