"Fossies" - the Fresh Open Source Software Archive

Member "jitsi-meet-5186/android/build.gradle" (30 Jul 2021, 7247 Bytes) of package /linux/misc/jitsi-meet-5186.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Java source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 import groovy.json.JsonSlurper
    2 import org.gradle.util.VersionNumber
    3 
    4 // Top-level build file where you can add configuration options common to all
    5 // sub-projects/modules.
    6 
    7 buildscript {
    8     repositories {
    9         google()
   10         jcenter()
   11     }
   12     dependencies {
   13         classpath 'com.android.tools.build:gradle:4.1.2'
   14         classpath 'com.google.gms:google-services:4.3.4'
   15         classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
   16     }
   17 }
   18 
   19 ext {
   20     buildToolsVersion = "30.0.3"
   21     compileSdkVersion = 30
   22     minSdkVersion    = 23
   23     targetSdkVersion = 30
   24     supportLibVersion = "28.0.0"
   25 
   26     // The Maven artifact groupdId of the third-party react-native modules which
   27     // Jitsi Meet SDK for Android depends on and which are not available in
   28     // third-party Maven repositories so we have to deploy to a Maven repository
   29     // of ours.
   30     moduleGroupId = 'com.facebook.react'
   31 
   32     // Maven repo where artifacts will be published
   33     mavenRepo = System.env.MVN_REPO ?: ""
   34     mavenUser = System.env.MVN_USER ?: ""
   35     mavenPassword = System.env.MVN_PASSWORD ?: ""
   36 
   37     // Libre build
   38     libreBuild = (System.env.LIBRE_BUILD ?: "false").toBoolean()
   39 
   40     googleServicesEnabled = project.file('app/google-services.json').exists() && !libreBuild
   41 }
   42 
   43 allprojects {
   44     repositories {
   45         google()
   46         jcenter()
   47         // React Native (JS, Obj-C sources, Android binaries) is installed from npm.
   48         maven { url "$rootDir/../node_modules/react-native/android" }
   49         // Android JSC is installed from npm.
   50         maven { url("$rootDir/../node_modules/jsc-android/dist") }
   51     }
   52 
   53     // Make sure we use the react-native version in node_modules and not the one
   54     // published in jcenter / elsewhere.
   55     configurations.all {
   56         resolutionStrategy {
   57             eachDependency { DependencyResolveDetails details ->
   58                 if (details.requested.group == 'com.facebook.react'
   59                         && details.requested.name == 'react-native') {
   60                     def file = new File("$rootDir/../node_modules/react-native/package.json")
   61                     def version = new JsonSlurper().parseText(file.text).version
   62                     details.useVersion version
   63                 }
   64             }
   65         }
   66     }
   67 
   68     // Third-party react-native modules which Jitsi Meet SDK for Android depends
   69     // on and which are not available in third-party Maven repositories need to
   70     // be deployed in a Maven repository of ours.
   71     //
   72 
   73     if (project.name.startsWith('react-native-')) {
   74         apply plugin: 'maven-publish'
   75         publishing {
   76             publications {}
   77             repositories {
   78                 maven {
   79                     url rootProject.ext.mavenRepo
   80                     if (!rootProject.ext.mavenRepo.startsWith("file")) {
   81                         credentials {
   82                             username rootProject.ext.mavenUser
   83                             password rootProject.ext.mavenPassword
   84                         }
   85                     }
   86                 }
   87             }
   88         }
   89     }
   90 
   91     // Use the number of seconds/10 since Jan 1 2019 as the version qualifier number.
   92     // This will last for the next ~680 years.
   93     // https://stackoverflow.com/a/38643838
   94     def versionQualifierNumber = (int)(((new Date().getTime()/1000) - 1546297200) / 10)
   95 
   96     afterEvaluate { project ->
   97         if (project.plugins.hasPlugin('android') || project.plugins.hasPlugin('android-library')) {
   98             project.android {
   99                 compileSdkVersion rootProject.ext.compileSdkVersion
  100                 buildToolsVersion rootProject.ext.buildToolsVersion
  101             }
  102         }
  103 
  104         if (project.name.startsWith('react-native-')) {
  105             def npmManifest = project.file('../package.json')
  106             def json = new JsonSlurper().parseText(npmManifest.text)
  107 
  108             // Release every dependency the SDK has with a -jitsi-XXX qualified version. This allows
  109             // us to pin the dependencies and make sure they are always updated, no matter what.
  110 
  111             project.version = "${json.version}-jitsi-${versionQualifierNumber}"
  112 
  113             task androidSourcesJar(type: Jar) {
  114                 classifier = 'sources'
  115                 from android.sourceSets.main.java.source
  116             }
  117 
  118             publishing.publications {
  119                 aarArchive(MavenPublication) {
  120                     groupId rootProject.ext.moduleGroupId
  121                     artifactId project.name
  122                     version project.version
  123 
  124                     artifact("${project.buildDir}/outputs/aar/${project.name}-release.aar") {
  125                         extension "aar"
  126                     }
  127                     artifact(androidSourcesJar)
  128                     pom.withXml {
  129                         def pomXml = asNode()
  130                         pomXml.appendNode('name', project.name)
  131                         pomXml.appendNode('description', json.description)
  132                         pomXml.appendNode('url', json.homepage)
  133                         if (json.license) {
  134                             def license = pomXml.appendNode('licenses').appendNode('license')
  135                             license.appendNode('name', json.license)
  136                             license.appendNode('distribution', 'repo')
  137                         }
  138 
  139                         def dependencies = pomXml.appendNode('dependencies')
  140                         configurations.getByName('releaseCompileClasspath').getResolvedConfiguration().getFirstLevelModuleDependencies().each {
  141                             def artifactId = it.moduleName
  142                             def version = it.moduleVersion
  143                             // React Native signals breaking changes by
  144                             // increasing the minor version number. So the
  145                             // (third-party) React Native modules we utilize can
  146                             // depend not on a specific react-native release but
  147                             // a wider range.
  148                             if (artifactId == 'react-native') {
  149                                 def versionNumber = VersionNumber.parse(version)
  150                                 version = "${versionNumber.major}.${versionNumber.minor}"
  151                             }
  152 
  153                             def dependency = dependencies.appendNode('dependency')
  154                             dependency.appendNode('groupId', it.moduleGroup)
  155                             dependency.appendNode('artifactId', artifactId)
  156                             dependency.appendNode('version', version)
  157                         }
  158                     }
  159                 }
  160             }
  161         }
  162     }
  163 }
  164 
  165 // Force the version of the Android build tools we have chosen on all
  166 // subprojects. The forcing was introduced for react-native and the third-party
  167 // modules that we utilize such as react-native-background-timer.
  168 subprojects { subproject ->
  169     afterEvaluate{
  170         if ((subproject.plugins.hasPlugin('android')
  171                     || subproject.plugins.hasPlugin('android-library'))
  172                 && rootProject.ext.has('buildToolsVersion')) {
  173             android {
  174                 buildToolsVersion rootProject.ext.buildToolsVersion
  175             }
  176         }
  177     }
  178 }