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

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