Skip to content

Commit 66cb71c

Browse files
committed
chore(): refactored build_canary.sh
1 parent 14c74c3 commit 66cb71c

File tree

1 file changed

+44
-20
lines changed

1 file changed

+44
-20
lines changed

build-support/build_canary.sh

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,58 @@ cp -r $ROOT_DIR/canaries/lib .
2424
cp $ROOT_DIR/build-support/dummy_amplifyconfiguration.dart lib/amplifyconfiguration.dart
2525

2626
# Android
27-
# TODO(tyllark): replace 'gradle*'' with 'gradle.kts' Flutter version is updated to 3.29.0 or higher
28-
sed -i '' -e "s/id \"com.android.application\" .*/id \"com.android.application\" version \"8.1.0\" apply false/" ./android/settings.gradle* #<3.29.0 only
29-
sed -i '' -e "s/id(\"com.android.application\") .*/id(\"com.android.application\") version \"8.1.0\" apply false/" ./android/settings.gradle*
27+
# Flutter >=3.29.0
28+
if [ -e ./android/settings.gradle.kts ]
29+
then
30+
sed -i '' -e "s/id(\"com.android.application\") .*/id(\"com.android.application\") version \"8.1.0\" apply false/" ./android/settings.gradle.kts
31+
sed -i '' -e "s/id(\"org.jetbrains.kotlin.android\") .*/id(\"org.jetbrains.kotlin.android\") version \"1.9.10\" apply false/" ./android/settings.gradle.kts
32+
cat ./android/settings.gradle.kts
3033

31-
sed -i '' -e "s/id \"org.jetbrains.kotlin.android\" .*/id \"org.jetbrains.kotlin.android\" version \"1.9.10\" apply false/" ./android/settings.gradle* #<3.29.0 only
32-
sed -i '' -e "s/id(\"org.jetbrains.kotlin.android\") .*/id(\"org.jetbrains.kotlin.android\") version \"1.9.10\" apply false/" ./android/settings.gradle*
33-
cat ./android/settings.gradle*
34+
# TODO(khatruong2009): remove this line after the next stable release (3.22.0 or 4.0)
35+
sed -i '' -e "s/minSdkVersion = .*/minSdkVersion = 24/" ./android/app/build.gradle.kts
36+
sed -i '' -e "s/minSdk = .*/minSdk = 24/" ./android/app/build.gradle.kts
3437

35-
# TODO(khatruong2009): remove this line after the next stable release (3.22.0 or 4.0)
36-
sed -i '' -e "s/minSdkVersion = .*/minSdkVersion = 24/" ./android/app/build.gradle*
37-
sed -i '' -e "s/minSdk = .*/minSdk = 24/" ./android/app/build.gradle*
38+
sed -i '' -e '/id "kotlin-android"/a\
39+
id '\''kotlin-parcelize'\''' ./android/app/build.gradle.kts
3840

39-
sed -i '' -e '/id "kotlin-android"/a\
40-
id '\''kotlin-parcelize'\''' ./android/app/build.gradle*
41+
sed -i '' -e "s/compileSdk = .*/compileSdk = 35/" ./android/app/build.gradle.kts
4142

42-
sed -i '' -e "s/compileSdk = .*/compileSdk = 35/" ./android/app/build.gradle*
43+
sed -i '' -e "s/sourceCompatibility = .*/sourceCompatibility = JavaVersion.VERSION_17/" ./android/app/build.gradle.kts
4344

44-
sed -i '' -e "s/sourceCompatibility = .*/sourceCompatibility = JavaVersion.VERSION_17/" ./android/app/build.gradle*
45+
# TODO(equartey): remove this line after the next stable release (3.22.0 or 4.0)
46+
sed -i '' -e "s/targetCompatibility = .*/targetCompatibility = JavaVersion.VERSION_17/" ./android/app/build.gradle.kts
4547

46-
# TODO(equartey): remove this line after the next stable release (3.22.0 or 4.0)
47-
sed -i '' -e "s/targetCompatibility = .*/targetCompatibility = JavaVersion.VERSION_17/" ./android/app/build.gradle*
48+
sed -i '' -e "s/compileOptions {.*/compileOptions {\n\t\tisCoreLibraryDesugaringEnabled = true/" ./android/app/build.gradle.kts
49+
sed -i '' -e "s/flutter {.*/dependencies {\n\tcoreLibraryDesugaring(\"com.android.tools:desugar_jdk_libs:2.0.3\")\n}\n\nflutter {/" ./android/app/build.gradle.kts
50+
cat ./android/app/build.gradle.kts
4851

49-
sed -i '' -e "s/compileOptions {.*/compileOptions {\n\t\tisCoreLibraryDesugaringEnabled = true/" ./android/app/build.gradle*
50-
sed -i '' -e "s/flutter {.*/dependencies {\n\tcoreLibraryDesugaring(\"com.android.tools:desugar_jdk_libs:2.0.3\")\n}\n\nflutter {/" ./android/app/build.gradle*
51-
cat ./android/app/build.gradle*
52+
sed -i '' -e "s#distributionUrl=.*#distributionUrl=https\\://services.gradle.org/distributions/gradle-8.9-all.zip#" ./android/gradle/wrapper/gradle-wrapper.properties
53+
cat ./android/gradle/wrapper/gradle-wrapper.properties
54+
# Flutter <3.29.0 (delete this else block when min Flutter SDK is bumped to 3.29.0 or higher)
55+
else
56+
sed -i '' -e "s/id \"com.android.application\" .*/id \"com.android.application\" version \"8.1.0\" apply false/" ./android/settings.gradle
57+
sed -i '' -e "s/id \"org.jetbrains.kotlin.android\" .*/id \"org.jetbrains.kotlin.android\" version \"1.9.10\" apply false/" ./android/settings.gradle
58+
cat ./android/settings.gradle
5259

53-
sed -i '' -e "s#distributionUrl=.*#distributionUrl=https\\://services.gradle.org/distributions/gradle-8.9-all.zip#" ./android/gradle/wrapper/gradle-wrapper.properties
54-
cat ./android/gradle/wrapper/gradle-wrapper.properties
60+
sed -i '' -e "s/minSdkVersion = .*/minSdkVersion = 24/" ./android/app/build.gradle
61+
sed -i '' -e "s/minSdk = .*/minSdk = 24/" ./android/app/build.gradle
62+
63+
sed -i '' -e '/id "kotlin-android"/a\
64+
id '\''kotlin-parcelize'\''' ./android/app/build.gradle
65+
66+
sed -i '' -e "s/compileSdk = .*/compileSdk = 35/" ./android/app/build.gradle
67+
68+
sed -i '' -e "s/sourceCompatibility = .*/sourceCompatibility = JavaVersion.VERSION_17/" ./android/app/build.gradle
69+
70+
sed -i '' -e "s/targetCompatibility = .*/targetCompatibility = JavaVersion.VERSION_17/" ./android/app/build.gradle
71+
72+
sed -i '' -e "s/compileOptions {.*/compileOptions {\n\t\tisCoreLibraryDesugaringEnabled = true/" ./android/app/build.gradle
73+
sed -i '' -e "s/flutter {.*/dependencies {\n\tcoreLibraryDesugaring(\"com.android.tools:desugar_jdk_libs:2.0.3\")\n}\n\nflutter {/" ./android/app/build.gradle
74+
cat ./android/app/build.gradle
75+
76+
sed -i '' -e "s#distributionUrl=.*#distributionUrl=https\\://services.gradle.org/distributions/gradle-8.9-all.zip#" ./android/gradle/wrapper/gradle-wrapper.properties
77+
cat ./android/gradle/wrapper/gradle-wrapper.properties
78+
fi
5579

5680
# iOS
5781
sed -i '' -e "s/# platform .*/platform :ios, '13.0'/" ./ios/Podfile

0 commit comments

Comments
 (0)