Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

build.gradle 9.9KB

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