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 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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.2.0'
  15. classpath 'io.fabric.tools:gradle:1.27.0'
  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. // If Android SDK is not installed, accept its license so that it
  147. // is automatically downloaded.
  148. afterEvaluate { project ->
  149. // Either the environment variable ANDROID_HOME or the property sdk.dir in
  150. // local.properties identifies where Android SDK is installed.
  151. def androidHome = System.env.ANDROID_HOME
  152. if (!androidHome) {
  153. // ANDROID_HOME is not set. Is sdk.dir set?
  154. def file = file("${project.rootDir}/local.properties")
  155. def props = new Properties()
  156. if (file.canRead()) {
  157. file.withInputStream {
  158. props.load(it)
  159. androidHome = props.'sdk.dir'
  160. }
  161. }
  162. if (!androidHome && (!file.exists() || file.canWrite())) {
  163. // Neither ANDROID_HOME nor sdk.dir is set. Set sdk.dir (because
  164. // environment variables cannot be set).
  165. props.'sdk.dir' = "${project.buildDir}/android-sdk".toString()
  166. file.withOutputStream {
  167. props.store(it, null)
  168. androidHome = props.'sdk.dir'
  169. }
  170. }
  171. }
  172. // If the license is not accepted, accept it so that automatic downloading
  173. // kicks in.
  174. // The license hash can be taken from the accepted licenses, by doing this
  175. // on your local machine the file is
  176. // ${androidHome}/licenses/android-sdk-license
  177. if (androidHome) {
  178. def dir = file("${androidHome}/licenses")
  179. dir.mkdirs()
  180. def file = file("${dir.path}/android-sdk-license")
  181. if (!file.exists()) {
  182. file.withWriter {
  183. def hash = 'd56f5187479451eabf01fb78af6dfcb131a6481e'
  184. it.write(hash, 0, hash.length())
  185. }
  186. }
  187. }
  188. }
  189. // Force the version of the Android build tools we have chosen on all
  190. // subprojects. The forcing was introduced for react-native and the third-party
  191. // modules that we utilize such as react-native-background-timer.
  192. subprojects { subproject ->
  193. afterEvaluate{
  194. if ((subproject.plugins.hasPlugin('android')
  195. || subproject.plugins.hasPlugin('android-library'))
  196. && rootProject.ext.has('buildToolsVersion')) {
  197. android {
  198. buildToolsVersion rootProject.ext.buildToolsVersion
  199. }
  200. }
  201. }
  202. }