Skip to content

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

fix(android): honor LIBRE_BUILD in the autolinking manifest

Calin-Teodor2aef6b59c2b7
diff --git a/android/sdk/build.gradle b/android/sdk/build.gradle
index a2bec03f15..aac2abb254 100644
--- a/android/sdk/build.gradle
+++ b/android/sdk/build.gradle
@@ -68,7 +68,7 @@ android {
def jitsiAutolinkOutDir = layout.buildDirectory.dir('generated/autolinking/src/main/jni')
def jitsiGenerateAutolinking = tasks.register('jitsiGenerateAutolinkingNewArchitectureFiles',
com.facebook.react.tasks.GenerateAutolinkingNewArchitecturesFileTask) {
- autolinkInputFile.set(rootProject.file('build/generated/autolinking/autolinking.json'))
+ autolinkInputFile.set(gradle.ext.autolinkingManifest)
generatedOutputDirectory.set(jitsiAutolinkOutDir)
}
@@ -114,17 +114,9 @@ dependencies {
(':react-native-device-info') : ['com.google.firebase', 'com.google.android.gms', 'com.android.installreferrer'],
(':react-native-google-signin-google-signin') : ['com.google.android.gms', 'androidx']
]
- // Only add these packages if we are NOT doing a LIBRE_BUILD
- def rnLibreExcluded = [
- ':amplitude-analytics-react-native',
- ':giphy-react-native-sdk',
- ':react-native-google-signin-google-signin'
- ]
+ // LIBRE_BUILD exclusions happen in settings.gradle.
(gradle.ext.autolinkedProjects ?: []).each { path ->
- if (rootProject.ext.libreBuild && rnLibreExcluded.contains(path)) {
- return
- }
def conf = rnApiModules.contains(path) ? 'api' : 'implementation'
dependencies.add(conf, project(path)) {
rnModuleExcludes.getOrDefault(path, []).each { grp -> exclude group: grp }
diff --git a/android/settings.gradle b/android/settings.gradle
index 5c87f2befb..8e04f6c660 100644
--- a/android/settings.gradle
+++ b/android/settings.gradle
@@ -1,11 +1,18 @@
+import groovy.json.JsonOutput
import groovy.json.JsonSlurper
include ':app', ':sdk'
includeBuild('../node_modules/@react-native/gradle-plugin')
-// Project paths of every autolinked RN module included below.
-// sdk/build.gradle consumes this instead of hardcoding names that can drift.
+// 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('build/generated/autolinking/autolinking.json')
@@ -15,6 +22,22 @@ if (!autolinkingJson.exists()) {
}
def json = new JsonSlurper().parseText(autolinkingJson.text)
+
+// Filtered here so the includes below and sdk/build.gradle's codegen agree.
+def autolinkingManifest = autolinkingJson
+if ((System.env.LIBRE_BUILD ?: 'false').toBoolean()) {
+ // 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 = file('build/generated/autolinking/autolinking-libre.json')
+ autolinkingManifest.text = JsonOutput.toJson(json)
+}
+gradle.ext.autolinkingManifest = autolinkingManifest
+
json.dependencies.each { name, config ->
if (config.platforms?.android?.sourceDir) {