From 4beb8c978262a78e0e00438b635598982e489563 Mon Sep 17 00:00:00 2001 From: Stefano Formicola Date: Wed, 24 May 2023 14:59:20 +0000 Subject: [PATCH 1/2] feat: add support for Android specific envs Variables whose key start with `ANDROID_` are rewritten without the platform prefix --- android/dotenv.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/android/dotenv.gradle b/android/dotenv.gradle index 22253756..7be3249f 100644 --- a/android/dotenv.gradle +++ b/android/dotenv.gradle @@ -52,7 +52,8 @@ def loadDotEnv(flavor = getCurrentFlavor()) { def matcher = (line =~ /^\s*(?:export\s+|)([\w\d\.\-_]+)\s*=\s*['"]?(.*?)?['"]?\s*$/) // TODO: Fail Android builds if line doesn't match if (matcher.getCount() == 1 && matcher[0].size() == 3) { - env.put(matcher[0][1], matcher[0][2].replace('"', '\\"')) + def key = matcher[0][1].replaceAll(/^ANDROID_/, '') + env.put(key, matcher[0][2].replace('"', '\\"')) } } } else { From 9984f720f8b2e7df5f362260c136a735fffda439 Mon Sep 17 00:00:00 2001 From: Stefano Formicola Date: Wed, 24 May 2023 15:39:05 +0000 Subject: [PATCH 2/2] feat(Android): ignore iOS specific envs --- android/dotenv.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/android/dotenv.gradle b/android/dotenv.gradle index 7be3249f..8a4e5b87 100644 --- a/android/dotenv.gradle +++ b/android/dotenv.gradle @@ -52,7 +52,11 @@ def loadDotEnv(flavor = getCurrentFlavor()) { def matcher = (line =~ /^\s*(?:export\s+|)([\w\d\.\-_]+)\s*=\s*['"]?(.*?)?['"]?\s*$/) // TODO: Fail Android builds if line doesn't match if (matcher.getCount() == 1 && matcher[0].size() == 3) { - def key = matcher[0][1].replaceAll(/^ANDROID_/, '') + def key = matcher[0][1] + if (key.startsWith("IOS_")) { + return + } + key = key.replaceAll(/^ANDROID_/, '') env.put(key, matcher[0][2].replace('"', '\\"')) } }