From d66d1dd3300bcc4e69aaac8e02d0aff560380d1c Mon Sep 17 00:00:00 2001 From: "Luong Vo (Lucas)" Date: Tue, 31 Oct 2023 22:35:00 +0700 Subject: [PATCH] [#30] Fix: generate the Android app module with the entered bundle id --- make_android.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/make_android.sh b/make_android.sh index e809a07..2516e35 100644 --- a/make_android.sh +++ b/make_android.sh @@ -33,25 +33,28 @@ sed -i '' "/ buildProjectAndRunTests()*/d" scripts/new_project.kts kscript scripts/new_project.kts package-name=${bundle_id} app-name=${project_name} template=compose +# Convert bundle_id with dot to packake folder path, e.g., co.nimblehq.kmm.template -> co/nimblehq/kmm/template +package_path="${bundle_id//.//}" + # Correct dependencies sed -i '' 's/Modules.DATA/Modules.SHARED/' sample/app/build.gradle.kts sed -i '' "/implementation(project(Modules.DOMAIN))*/d" sample/app/build.gradle.kts sed -i '' "/kover(project(Modules.DOMAIN))*/d" sample/app/build.gradle.kts # Correct imports -sed -i '' 's/import co.nimblehq.kmm.template.data.di.initKoin/import co.nimblehq.kmm.template.di.initKoin/' sample/app/src/main/java/co/nimblehq/kmm/template/MainApplication.kt +sed -i '' 's/import '$bundle_id'.data.di.initKoin/import '$bundle_id'.di.initKoin/' sample/app/src/main/java/$package_path/MainApplication.kt # Correct error mapping -sed -i '' 's/is ApiException -> error?.message/is ApiException -> message/' sample/app/src/main/java/co/nimblehq/kmm/template/ui/ErrorMapping.kt +sed -i '' 's/is ApiException -> error?.message/is ApiException -> message/' sample/app/src/main/java/$package_path/ui/ErrorMapping.kt # Remove unnecessary definition of BASE_API_URL sed -i '' "/buildConfigField(\"String\", \"BASE_API_URL\"*/d" sample/app/build.gradle.kts -sed -i '' "/import co.nimblehq.kmm.template.BuildConfig*/d" sample/app/src/main/java/co/nimblehq/kmm/template/di/modules/AppModule.kt -sed -i '' "/import co.nimblehq.kmm.template.data.di.modules.BASE_API_URL*/d" sample/app/src/main/java/co/nimblehq/kmm/template/di/modules/AppModule.kt -sed -i '' "/import org.koin.core.qualifier.named*/d" sample/app/src/main/java/co/nimblehq/kmm/template/di/modules/AppModule.kt -sed -i '' "/ single(named(BASE_API_URL)) {\n*/d" sample/app/src/main/java/co/nimblehq/kmm/template/di/modules/AppModule.kt -sed -i '' "/ BuildConfig.BASE_API_URL\n*/d" sample/app/src/main/java/co/nimblehq/kmm/template/di/modules/AppModule.kt -sed -i '' "/ }\n*/d" sample/app/src/main/java/co/nimblehq/kmm/template/di/modules/AppModule.kt +sed -i '' "/import $bundle_id.BuildConfig*/d" sample/app/src/main/java/$package_path/di/modules/AppModule.kt +sed -i '' "/import $bundle_id.data.di.modules.BASE_API_URL*/d" sample/app/src/main/java/$package_path/di/modules/AppModule.kt +sed -i '' "/import org.koin.core.qualifier.named*/d" sample/app/src/main/java/$package_path/di/modules/AppModule.kt +sed -i '' "/ single(named(BASE_API_URL)) {\n*/d" sample/app/src/main/java/$package_path/di/modules/AppModule.kt +sed -i '' "/ BuildConfig.BASE_API_URL\n*/d" sample/app/src/main/java/$package_path/di/modules/AppModule.kt +sed -i '' "/ }\n*/d" sample/app/src/main/java/$package_path/di/modules/AppModule.kt # Overwrite custom files rsync -av ../custom/android/ sample/app/