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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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.0.1'
  10. // NOTE: Do not place your application dependencies here; they belong
  11. // in the individual module build.gradle files.
  12. }
  13. }
  14. allprojects {
  15. repositories {
  16. google()
  17. jcenter()
  18. maven { url "$rootDir/../node_modules/jsc-android/dist" }
  19. // React Native (JS, Obj-C sources, Android binaries) is installed from
  20. // npm.
  21. maven { url "$rootDir/../node_modules/react-native/android" }
  22. }
  23. // Make sure we use the react-native version in node_modules and not the one
  24. // published in jcenter / elsewhere.
  25. configurations.all {
  26. resolutionStrategy {
  27. eachDependency { DependencyResolveDetails details ->
  28. if (details.requested.group == 'com.facebook.react'
  29. && details.requested.name == 'react-native') {
  30. def file = new File("$rootDir/../node_modules/react-native/package.json")
  31. def version = new groovy.json.JsonSlurper().parseText(file.text).version
  32. details.useVersion version
  33. }
  34. if (details.requested.group == 'org.webkit'
  35. && details.requested.name == 'android-jsc') {
  36. def file = new File("$rootDir/../node_modules/jsc-android/package.json")
  37. def version = new groovy.json.JsonSlurper().parseText(file.text).version
  38. details.useVersion "r${version.tokenize('.')[0]}"
  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 { url "file:${rootProject.projectDir}/../../../jitsi/jitsi-maven-repository/releases" }
  53. }
  54. }
  55. }
  56. afterEvaluate { project ->
  57. if (project.name.startsWith('react-native-')) {
  58. def npmManifest = project.file('../package.json')
  59. def json = new groovy.json.JsonSlurper().parseText(npmManifest.text)
  60. // React Native modules have an npm peer dependency on react-native,
  61. // they do not have an npm dependency on it. Further below though we
  62. // choose a react-native version (range) when we represent them as
  63. // Maven artifacts. Effectively, we are forking the projects by not
  64. // complying with the full range of their npm peer dependency and,
  65. // consequently, we should qualify their version.
  66. def versionQualifier = '-jitsi-1'
  67. if ('react-native-webrtc'.equals(project.name))
  68. versionQualifier = '-jitsi-1'
  69. project.version = "${json.version}${versionQualifier}"
  70. project.android {
  71. compileSdkVersion rootProject.ext.compileSdkVersion
  72. if (rootProject.ext.has('buildToolsVersion')) {
  73. buildToolsVersion rootProject.ext.buildToolsVersion
  74. }
  75. defaultConfig {
  76. minSdkVersion rootProject.ext.minSdkVersion
  77. targetSdkVersion rootProject.ext.targetSdkVersion
  78. }
  79. }
  80. task androidJavadocs(type: Javadoc) {
  81. source = android.sourceSets.main.java.source
  82. classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
  83. failOnError false
  84. }
  85. task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
  86. classifier = 'javadoc'
  87. from androidJavadocs.destinationDir
  88. }
  89. task androidSourcesJar(type: Jar) {
  90. classifier = 'sources'
  91. from android.sourceSets.main.java.source
  92. }
  93. publishing.publications {
  94. aarArchive(MavenPublication) {
  95. groupId rootProject.ext.moduleGroupId
  96. artifactId project.name
  97. version project.version
  98. artifact("${project.buildDir}/outputs/aar/${project.name}-release.aar") {
  99. extension "aar"
  100. }
  101. artifact(androidSourcesJar)
  102. artifact(androidJavadocsJar)
  103. pom.withXml {
  104. def pomXml = asNode()
  105. pomXml.appendNode('name', project.name)
  106. pomXml.appendNode('description', json.description)
  107. pomXml.appendNode('url', json.homepage)
  108. if (json.license) {
  109. def license = pomXml.appendNode('licenses').appendNode('license')
  110. license.appendNode('name', json.license)
  111. license.appendNode('distribution', 'repo')
  112. }
  113. def dependencies = pomXml.appendNode('dependencies')
  114. configurations.getByName('releaseCompileClasspath').getResolvedConfiguration().getFirstLevelModuleDependencies().each {
  115. def artifactId = it.moduleName
  116. def version = it.moduleVersion
  117. // React Native signals breaking changes by
  118. // increasing the minor version number. So the
  119. // (third-party) React Native modules we utilize can
  120. // depend not on a specific react-native release but
  121. // a wider range.
  122. if (artifactId.equals('react-native')) {
  123. def versionNumber = VersionNumber.parse(version)
  124. version = "${versionNumber.major}.${versionNumber.minor}"
  125. }
  126. def dependency = dependencies.appendNode('dependency')
  127. dependency.appendNode('groupId', it.moduleGroup)
  128. dependency.appendNode('artifactId', artifactId)
  129. dependency.appendNode('version', version)
  130. }
  131. }
  132. }
  133. }
  134. }
  135. }
  136. }
  137. ext {
  138. buildToolsVersion = "26.0.2"
  139. compileSdkVersion = 26
  140. minSdkVersion = 21
  141. targetSdkVersion = 26
  142. // The Maven artifact groupdId of the third-party react-native modules which
  143. // Jitsi Meet SDK for Android depends on and which are not available in
  144. // third-party Maven repositories so we have to deploy to a Maven repository
  145. // of ours.
  146. moduleGroupId = 'com.facebook.react'
  147. }
  148. // Force the version of the Android build tools we have chosen on all
  149. // subprojects. The forcing was introduced for react-native and the third-party
  150. // modules that we utilize such as react-native-background-timer.
  151. subprojects { subproject ->
  152. afterEvaluate{
  153. if ((subproject.plugins.hasPlugin('android')
  154. || subproject.plugins.hasPlugin('android-library'))
  155. && rootProject.ext.has('buildToolsVersion')) {
  156. android {
  157. buildToolsVersion rootProject.ext.buildToolsVersion
  158. }
  159. }
  160. }
  161. }