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.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. // Top-level build file where you can add configuration options common to all
  2. // sub-projects/modules.
  3. buildscript {
  4. repositories {
  5. google()
  6. jcenter()
  7. }
  8. dependencies {
  9. classpath 'com.android.tools.build:gradle:3.1.4'
  10. classpath 'com.google.gms:google-services:3.2.1'
  11. // NOTE: Do not place your application dependencies here; they belong
  12. // in the individual module build.gradle files.
  13. }
  14. }
  15. allprojects {
  16. repositories {
  17. maven { url "https://maven.google.com" }
  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 groovy.json.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 groovy.json.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/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 groovy.json.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-webrtc'.equals(project.name))
  70. versionQualifier = '-jitsi-1'
  71. project.version = "${json.version}${versionQualifier}"
  72. project.android {
  73. compileSdkVersion rootProject.ext.compileSdkVersion
  74. if (rootProject.ext.has('buildToolsVersion')) {
  75. buildToolsVersion rootProject.ext.buildToolsVersion
  76. }
  77. defaultConfig {
  78. minSdkVersion rootProject.ext.minSdkVersion
  79. targetSdkVersion rootProject.ext.targetSdkVersion
  80. }
  81. }
  82. task androidJavadocs(type: Javadoc) {
  83. source = android.sourceSets.main.java.source
  84. classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
  85. failOnError false
  86. }
  87. task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
  88. classifier = 'javadoc'
  89. from androidJavadocs.destinationDir
  90. }
  91. task androidSourcesJar(type: Jar) {
  92. classifier = 'sources'
  93. from android.sourceSets.main.java.source
  94. }
  95. publishing.publications {
  96. aarArchive(MavenPublication) {
  97. groupId rootProject.ext.moduleGroupId
  98. artifactId project.name
  99. version project.version
  100. artifact("${project.buildDir}/outputs/aar/${project.name}-release.aar") {
  101. extension "aar"
  102. }
  103. artifact(androidSourcesJar)
  104. artifact(androidJavadocsJar)
  105. pom.withXml {
  106. def pomXml = asNode()
  107. pomXml.appendNode('name', project.name)
  108. pomXml.appendNode('description', json.description)
  109. pomXml.appendNode('url', json.homepage)
  110. if (json.license) {
  111. def license = pomXml.appendNode('licenses').appendNode('license')
  112. license.appendNode('name', json.license)
  113. license.appendNode('distribution', 'repo')
  114. }
  115. def dependencies = pomXml.appendNode('dependencies')
  116. configurations.getByName('releaseCompileClasspath').getResolvedConfiguration().getFirstLevelModuleDependencies().each {
  117. def artifactId = it.moduleName
  118. def version = it.moduleVersion
  119. // React Native signals breaking changes by
  120. // increasing the minor version number. So the
  121. // (third-party) React Native modules we utilize can
  122. // depend not on a specific react-native release but
  123. // a wider range.
  124. if (artifactId.equals('react-native')) {
  125. def versionNumber = VersionNumber.parse(version)
  126. version = "${versionNumber.major}.${versionNumber.minor}"
  127. }
  128. def dependency = dependencies.appendNode('dependency')
  129. dependency.appendNode('groupId', it.moduleGroup)
  130. dependency.appendNode('artifactId', artifactId)
  131. dependency.appendNode('version', version)
  132. }
  133. }
  134. }
  135. }
  136. }
  137. }
  138. }
  139. ext {
  140. buildToolsVersion = "27.0.3"
  141. compileSdkVersion = 27
  142. minSdkVersion = 21
  143. targetSdkVersion = 26
  144. supportLibVersion = "27.1.1"
  145. // The Maven artifact groupdId of the third-party react-native modules which
  146. // Jitsi Meet SDK for Android depends on and which are not available in
  147. // third-party Maven repositories so we have to deploy to a Maven repository
  148. // of ours.
  149. moduleGroupId = 'com.facebook.react'
  150. }
  151. // Force the version of the Android build tools we have chosen on all
  152. // subprojects. The forcing was introduced for react-native and the third-party
  153. // modules that we utilize such as react-native-background-timer.
  154. subprojects { subproject ->
  155. afterEvaluate{
  156. if ((subproject.plugins.hasPlugin('android')
  157. || subproject.plugins.hasPlugin('android-library'))
  158. && rootProject.ext.has('buildToolsVersion')) {
  159. android {
  160. buildToolsVersion rootProject.ext.buildToolsVersion
  161. }
  162. }
  163. }
  164. }
  165. task wrapper(type: Wrapper) {
  166. gradleVersion = '4.4'
  167. distributionUrl = distributionUrl.replace("bin", "all")
  168. }