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

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