Skip to content

Commit

Permalink
refactor: update build.gradle to disable minification and resource sh…
Browse files Browse the repository at this point in the history
…rinking for Plaid Connect
  • Loading branch information
sharjeelyunus committed Dec 30, 2024
1 parent 04b7890 commit 0487db6
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions starter/scripts/modules/enable_connect.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import 'dart:io';

import '../constants.dart';
import '../utils.dart';
import '../utils/firebase_utils.dart';
import '../utils/proguard_utils.dart';

void main(List<String> arguments) async {
List<String> platforms = getPlatforms(arguments);
Expand Down Expand Up @@ -49,11 +47,11 @@ ensemble_connect:
updatePubspec(pubspecDependencies);

if (platforms.contains('android')) {
createProguardRules(connectProguardRules);
addImplementationDependency(
"implementation 'org.openjsse:openjsse:1.1.10'");
addImplementationDependency(
"implementation 'org.conscrypt:conscrypt-android:2.5.2'");
updateBuildGradle(minifyEnabled: false, shrinkResources: false);
}

if (platforms.contains('ios')) {
Expand All @@ -78,3 +76,25 @@ ensemble_connect:
exit(1);
}
}

void updateBuildGradle(
{bool minifyEnabled = false, bool shrinkResources = false}) {
final buildGradleFile = File('android/app/build.gradle');
String content = buildGradleFile.readAsStringSync();

if (!content.contains('minifyEnabled')) {
content = content.replaceAllMapped(
RegExp(r'buildTypes\s*{[^}]*release\s*{', multiLine: true),
(match) =>
"buildTypes {\n release {\n minifyEnabled $minifyEnabled");
}

if (!content.contains('shrinkResources')) {
content = content.replaceAllMapped(
RegExp(r'buildTypes\s*{[^}]*release\s*{', multiLine: true),
(match) =>
"buildTypes {\n release {\n shrinkResources $shrinkResources");
}

buildGradleFile.writeAsStringSync(content);
}

0 comments on commit 0487db6

Please sign in to comment.