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 8.9KB

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