"Fossies" - the Fresh Open Source Software Archive

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