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

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