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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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.2.1'
  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. maven { url "$rootDir/../node_modules/jsc-android/dist" }
  25. // React Native (JS, Obj-C sources, Android binaries) is installed from
  26. // npm.
  27. maven { url "$rootDir/../node_modules/react-native/android" }
  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. if (details.requested.group == 'org.webkit'
  41. && details.requested.name == 'android-jsc') {
  42. def file = new File("$rootDir/../node_modules/jsc-android/package.json")
  43. def version = new JsonSlurper().parseText(file.text).version
  44. details.useVersion "r${version.tokenize('.')[0]}"
  45. }
  46. }
  47. }
  48. }
  49. // Third-party react-native modules which Jitsi Meet SDK for Android depends
  50. // on and which are not available in third-party Maven repositories need to
  51. // be deployed in a Maven repository of ours.
  52. //
  53. if (project.name.startsWith('react-native-')) {
  54. apply plugin: 'maven-publish'
  55. publishing {
  56. publications {}
  57. repositories {
  58. maven { url "file:${rootProject.projectDir}/../../jitsi-maven-repository/releases" }
  59. }
  60. }
  61. }
  62. afterEvaluate { project ->
  63. if (project.name.startsWith('react-native-')) {
  64. def npmManifest = project.file('../package.json')
  65. def json = new JsonSlurper().parseText(npmManifest.text)
  66. // React Native modules have an npm peer dependency on react-native,
  67. // they do not have an npm dependency on it. Further below though we
  68. // choose a react-native version (range) when we represent them as
  69. // Maven artifacts. Effectively, we are forking the projects by not
  70. // complying with the full range of their npm peer dependency and,
  71. // consequently, we should qualify their version.
  72. def versionQualifier = '-jitsi-1'
  73. if ('react-native-background-timer' == project.name)
  74. versionQualifier = '-jitsi-3' // 2.0.0 + react-native 0.57
  75. else if ('react-native-calendar-events' == project.name)
  76. versionQualifier = '-jitsi-2' // 1.6.4 + react-native 0.57
  77. else if ('react-native-fast-image' == project.name)
  78. versionQualifier = '-jitsi-2' // 5.1.1 + react-native 0.57
  79. else if ('react-native-google-signin' == project.name)
  80. versionQualifier = '-jitsi-2' // 1.0.2 + react-native 0.57
  81. else if ('react-native-immersive' == project.name)
  82. versionQualifier = '-jitsi-5' // 2.0.0 + react-native 0.57
  83. else if ('react-native-keep-awake' == project.name)
  84. versionQualifier = '-jitsi-4' // 4.0.0 + react-native 0.57
  85. else if ('react-native-linear-gradient' == project.name)
  86. versionQualifier = '-jitsi-1' // 2.4.0 + react-native 0.57
  87. else if ('react-native-sound' == project.name)
  88. versionQualifier = '-jitsi-2' // 0.10.9 + react-native 0.57
  89. else if ('react-native-vector-icons' == project.name)
  90. versionQualifier = '-jitsi-3' // 6.0.2 + react-native 0.57
  91. else if ('react-native-webrtc' == project.name)
  92. versionQualifier = '-jitsi-9' // 6322a9b5a38ce590cfaea4041072ea87c8dbf558 + react-native 0.57
  93. project.version = "${json.version}${versionQualifier}"
  94. project.android {
  95. compileSdkVersion rootProject.ext.compileSdkVersion
  96. if (rootProject.ext.has('buildToolsVersion')) {
  97. buildToolsVersion rootProject.ext.buildToolsVersion
  98. }
  99. defaultConfig {
  100. minSdkVersion rootProject.ext.minSdkVersion
  101. targetSdkVersion rootProject.ext.targetSdkVersion
  102. }
  103. }
  104. task androidJavadocs(type: Javadoc) {
  105. source = android.sourceSets.main.java.source
  106. classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
  107. failOnError false
  108. }
  109. task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
  110. classifier = 'javadoc'
  111. from androidJavadocs.destinationDir
  112. }
  113. task androidSourcesJar(type: Jar) {
  114. classifier = 'sources'
  115. from android.sourceSets.main.java.source
  116. }
  117. publishing.publications {
  118. aarArchive(MavenPublication) {
  119. groupId rootProject.ext.moduleGroupId
  120. artifactId project.name
  121. version project.version
  122. artifact("${project.buildDir}/outputs/aar/${project.name}-release.aar") {
  123. extension "aar"
  124. }
  125. artifact(androidSourcesJar)
  126. artifact(androidJavadocsJar)
  127. pom.withXml {
  128. def pomXml = asNode()
  129. pomXml.appendNode('name', project.name)
  130. pomXml.appendNode('description', json.description)
  131. pomXml.appendNode('url', json.homepage)
  132. if (json.license) {
  133. def license = pomXml.appendNode('licenses').appendNode('license')
  134. license.appendNode('name', json.license)
  135. license.appendNode('distribution', 'repo')
  136. }
  137. def dependencies = pomXml.appendNode('dependencies')
  138. configurations.getByName('releaseCompileClasspath').getResolvedConfiguration().getFirstLevelModuleDependencies().each {
  139. def artifactId = it.moduleName
  140. def version = it.moduleVersion
  141. // React Native signals breaking changes by
  142. // increasing the minor version number. So the
  143. // (third-party) React Native modules we utilize can
  144. // depend not on a specific react-native release but
  145. // a wider range.
  146. if (artifactId == 'react-native') {
  147. def versionNumber = VersionNumber.parse(version)
  148. version = "${versionNumber.major}.${versionNumber.minor}"
  149. }
  150. def dependency = dependencies.appendNode('dependency')
  151. dependency.appendNode('groupId', it.moduleGroup)
  152. dependency.appendNode('artifactId', artifactId)
  153. dependency.appendNode('version', version)
  154. }
  155. }
  156. }
  157. }
  158. }
  159. }
  160. }
  161. ext {
  162. buildToolsVersion = "28.0.3"
  163. compileSdkVersion = 28
  164. minSdkVersion = 21
  165. targetSdkVersion = 28
  166. supportLibVersion = "28.0.0"
  167. // The Maven artifact groupdId of the third-party react-native modules which
  168. // Jitsi Meet SDK for Android depends on and which are not available in
  169. // third-party Maven repositories so we have to deploy to a Maven repository
  170. // of ours.
  171. moduleGroupId = 'com.facebook.react'
  172. // Glide
  173. excludeAppGlideModule = true
  174. glideVersion = "4.7.1" // keep in sync with react-native-fast-image
  175. }
  176. // If Android SDK is not installed, accept its license so that it
  177. // is automatically downloaded.
  178. afterEvaluate { project ->
  179. // Either the environment variable ANDROID_HOME or the property sdk.dir in
  180. // local.properties identifies where Android SDK is installed.
  181. def androidHome = System.env.ANDROID_HOME
  182. if (!androidHome) {
  183. // ANDROID_HOME is not set. Is sdk.dir set?
  184. def file = file("${project.rootDir}/local.properties")
  185. def props = new Properties()
  186. if (file.canRead()) {
  187. file.withInputStream {
  188. props.load(it)
  189. androidHome = props.'sdk.dir'
  190. }
  191. }
  192. if (!androidHome && (!file.exists() || file.canWrite())) {
  193. // Neither ANDROID_HOME nor sdk.dir is set. Set sdk.dir (because
  194. // environment variables cannot be set).
  195. props.'sdk.dir' = "${project.buildDir}/android-sdk".toString()
  196. file.withOutputStream {
  197. props.store(it, null)
  198. androidHome = props.'sdk.dir'
  199. }
  200. }
  201. }
  202. // If the license is not accepted, accept it so that automatic downloading
  203. // kicks in.
  204. // The license hash can be taken from the accepted licenses, by doing this
  205. // on your local machine the file is
  206. // ${androidHome}/licenses/android-sdk-license
  207. if (androidHome) {
  208. def dir = file("${androidHome}/licenses")
  209. dir.mkdirs()
  210. def file = file("${dir.path}/android-sdk-license")
  211. if (!file.exists()) {
  212. file.withWriter {
  213. def hash = 'd56f5187479451eabf01fb78af6dfcb131a6481e'
  214. it.write(hash, 0, hash.length())
  215. }
  216. }
  217. }
  218. }
  219. // Force the version of the Android build tools we have chosen on all
  220. // subprojects. The forcing was introduced for react-native and the third-party
  221. // modules that we utilize such as react-native-background-timer.
  222. subprojects { subproject ->
  223. afterEvaluate{
  224. if ((subproject.plugins.hasPlugin('android')
  225. || subproject.plugins.hasPlugin('android-library'))
  226. && rootProject.ext.has('buildToolsVersion')) {
  227. android {
  228. buildToolsVersion rootProject.ext.buildToolsVersion
  229. }
  230. }
  231. }
  232. }