Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

2.0 KB
Raw Blame
import groovy.json.JsonOutput
import groovy.json.JsonSlurper

include ':app', ':sdk'

includeBuild('../node_modules/@react-native/gradle-plugin')

// Non-free RN modules, excluded when LIBRE_BUILD is set.
def libreExcludedModules = [
    '@amplitude/analytics-react-native',
    '@giphy/react-native-sdk',
    '@react-native-google-signin/google-signin'
]

// Autolinked RN module paths, consumed by sdk/build.gradle.
gradle.ext.autolinkedProjects = []

def autolinkingJson = file('../node_modules/.jitsi/autolinking.json')
if (!autolinkingJson.exists()) {
    throw new IllegalStateException(
        "Missing ${autolinkingJson}. Run `npm run android-autolinking` before building.")
}

def json = new JsonSlurper().parseText(autolinkingJson.text)
def libreBuild = (System.env.LIBRE_BUILD ?: 'false').toBoolean()

if (json.libreBuild && !libreBuild) {
    logger.warn("${autolinkingJson} was generated with LIBRE_BUILD; non-free modules are excluded. " +
        'Run `npm run android-autolinking` to include them.')
}

// Filtered here so the includes below and sdk/build.gradle's codegen agree.
def autolinkingManifest = autolinkingJson
if (libreBuild) {
    // Fail loudly if the list above was patched away.
    if (libreExcludedModules.isEmpty()) {
        throw new IllegalStateException('LIBRE_BUILD is set but libreExcludedModules is empty.')
    }

    libreExcludedModules.each { json.dependencies.remove(it) }

    autolinkingManifest = new File(autolinkingJson.parentFile, 'autolinking-libre.json')
    autolinkingManifest.text = JsonOutput.toJson(json)
}
gradle.ext.autolinkingManifest = autolinkingManifest

json.dependencies.each { name, config ->
    if (config.platforms?.android?.sourceDir) {

        def projectName = name.replace('@', '').replace('/', '-')
        def sourceDir = config.platforms.android.sourceDir

        include ":$projectName"
        project(":$projectName").projectDir = new File(sourceDir)
        gradle.ext.autolinkedProjects << ":$projectName".toString()
    }
}