Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

build.gradle 8.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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.ext.mavenRepo}" }
  52. }
  53. }
  54. }
  55. // Use the number of seconds/10 since Jan 1 2019 as the version qualifier number.
  56. // This will last for the next ~680 years.
  57. // https://stackoverflow.com/a/38643838
  58. def versionQualifierNumber = (int)(((new Date().getTime()/1000) - 1546297200) / 10)
  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. // Release every dependency the SDK has with a -jitsi-XXX qualified version. This allows
  64. // us to pin the dependencies and make sure they are always updated, no matter what.
  65. project.version = "${json.version}-jitsi-${versionQualifierNumber}"
  66. project.android {
  67. compileSdkVersion rootProject.ext.compileSdkVersion
  68. if (rootProject.ext.has('buildToolsVersion')) {
  69. buildToolsVersion rootProject.ext.buildToolsVersion
  70. }
  71. defaultConfig {
  72. minSdkVersion rootProject.ext.minSdkVersion
  73. targetSdkVersion rootProject.ext.targetSdkVersion
  74. }
  75. }
  76. task androidSourcesJar(type: Jar) {
  77. classifier = 'sources'
  78. from android.sourceSets.main.java.source
  79. }
  80. publishing.publications {
  81. aarArchive(MavenPublication) {
  82. groupId rootProject.ext.moduleGroupId
  83. artifactId project.name
  84. version project.version
  85. artifact("${project.buildDir}/outputs/aar/${project.name}-release.aar") {
  86. extension "aar"
  87. }
  88. artifact(androidSourcesJar)
  89. pom.withXml {
  90. def pomXml = asNode()
  91. pomXml.appendNode('name', project.name)
  92. pomXml.appendNode('description', json.description)
  93. pomXml.appendNode('url', json.homepage)
  94. if (json.license) {
  95. def license = pomXml.appendNode('licenses').appendNode('license')
  96. license.appendNode('name', json.license)
  97. license.appendNode('distribution', 'repo')
  98. }
  99. def dependencies = pomXml.appendNode('dependencies')
  100. configurations.getByName('releaseCompileClasspath').getResolvedConfiguration().getFirstLevelModuleDependencies().each {
  101. def artifactId = it.moduleName
  102. def version = it.moduleVersion
  103. // React Native signals breaking changes by
  104. // increasing the minor version number. So the
  105. // (third-party) React Native modules we utilize can
  106. // depend not on a specific react-native release but
  107. // a wider range.
  108. if (artifactId == 'react-native') {
  109. def versionNumber = VersionNumber.parse(version)
  110. version = "${versionNumber.major}.${versionNumber.minor}"
  111. }
  112. def dependency = dependencies.appendNode('dependency')
  113. dependency.appendNode('groupId', it.moduleGroup)
  114. dependency.appendNode('artifactId', artifactId)
  115. dependency.appendNode('version', version)
  116. }
  117. }
  118. }
  119. }
  120. }
  121. }
  122. }
  123. ext {
  124. buildToolsVersion = "28.0.3"
  125. compileSdkVersion = 28
  126. minSdkVersion = 21
  127. targetSdkVersion = 28
  128. supportLibVersion = "28.0.0"
  129. // The Maven artifact groupdId of the third-party react-native modules which
  130. // Jitsi Meet SDK for Android depends on and which are not available in
  131. // third-party Maven repositories so we have to deploy to a Maven repository
  132. // of ours.
  133. moduleGroupId = 'com.facebook.react'
  134. // Maven repo where artifacts will be published
  135. mavenRepo = System.env.MVN_REPO ?: "${rootProject.projectDir}/../../jitsi-maven-repository/releases"
  136. // Glide
  137. excludeAppGlideModule = true
  138. glideVersion = "4.7.1" // keep in sync with react-native-fast-image
  139. }
  140. // If Android SDK is not installed, accept its license so that it
  141. // is automatically downloaded.
  142. afterEvaluate { project ->
  143. // Either the environment variable ANDROID_HOME or the property sdk.dir in
  144. // local.properties identifies where Android SDK is installed.
  145. def androidHome = System.env.ANDROID_HOME
  146. if (!androidHome) {
  147. // ANDROID_HOME is not set. Is sdk.dir set?
  148. def file = file("${project.rootDir}/local.properties")
  149. def props = new Properties()
  150. if (file.canRead()) {
  151. file.withInputStream {
  152. props.load(it)
  153. androidHome = props.'sdk.dir'
  154. }
  155. }
  156. if (!androidHome && (!file.exists() || file.canWrite())) {
  157. // Neither ANDROID_HOME nor sdk.dir is set. Set sdk.dir (because
  158. // environment variables cannot be set).
  159. props.'sdk.dir' = "${project.buildDir}/android-sdk".toString()
  160. file.withOutputStream {
  161. props.store(it, null)
  162. androidHome = props.'sdk.dir'
  163. }
  164. }
  165. }
  166. // If the license is not accepted, accept it so that automatic downloading
  167. // kicks in.
  168. // The license hash can be taken from the accepted licenses, by doing this
  169. // on your local machine the file is
  170. // ${androidHome}/licenses/android-sdk-license
  171. if (androidHome) {
  172. def dir = file("${androidHome}/licenses")
  173. dir.mkdirs()
  174. def file = file("${dir.path}/android-sdk-license")
  175. if (!file.exists()) {
  176. file.withWriter {
  177. def hash = 'd56f5187479451eabf01fb78af6dfcb131a6481e'
  178. it.write(hash, 0, hash.length())
  179. }
  180. }
  181. }
  182. }
  183. // Force the version of the Android build tools we have chosen on all
  184. // subprojects. The forcing was introduced for react-native and the third-party
  185. // modules that we utilize such as react-native-background-timer.
  186. subprojects { subproject ->
  187. afterEvaluate{
  188. if ((subproject.plugins.hasPlugin('android')
  189. || subproject.plugins.hasPlugin('android-library'))
  190. && rootProject.ext.has('buildToolsVersion')) {
  191. android {
  192. buildToolsVersion rootProject.ext.buildToolsVersion
  193. }
  194. }
  195. }
  196. }