From ab06f86e1dc864cf98cca8d894126dbb9c69696e Mon Sep 17 00:00:00 2001 From: Mustafa Ozhan Date: Mon, 16 Jan 2023 22:49:51 +0200 Subject: [PATCH] [Oztechan/CCC#1705] Create Submodules structure for Git submodules (#1714) * [Oztechan/CCC#1705] Create Submodules structure for Git submodules * [Oztechan/CCC#1705] Create Submodules structure for Git submodules * [Oztechan/CCC#1705] Create Submodules structure for Git submodules --- ad/build.gradle.kts | 2 +- analytics/build.gradle.kts | 2 +- android/build.gradle.kts | 22 +++++++------- backend/build.gradle.kts | 8 ++--- billing/build.gradle.kts | 6 ++-- buildSrc/src/main/kotlin/Modules.kt | 45 +++++++++++++++-------------- client/build.gradle.kts | 16 +++++----- common/build.gradle.kts | 4 +-- config/build.gradle.kts | 4 +-- provider/build.gradle.kts | 10 +++---- res/build.gradle.kts | 2 +- settings.gradle.kts | 16 +++++----- test/build.gradle.kts | 2 +- 13 files changed, 71 insertions(+), 68 deletions(-) diff --git a/ad/build.gradle.kts b/ad/build.gradle.kts index ba8cb5585c..8c32971492 100644 --- a/ad/build.gradle.kts +++ b/ad/build.gradle.kts @@ -67,5 +67,5 @@ dependencies { @Suppress("UnstableApiUsage") DeviceFlavour.googleImplementation(libs.android.google.admob) - implementation(project(Modules.logmob.path)) + implementation(project(Modules.Submodules.logmob)) } diff --git a/analytics/build.gradle.kts b/analytics/build.gradle.kts index 777bdac881..17ee951c25 100644 --- a/analytics/build.gradle.kts +++ b/analytics/build.gradle.kts @@ -23,7 +23,7 @@ kotlin { } val commonTest by getting { dependencies { - implementation(project(Modules.test.path)) + implementation(project(Modules.test)) } } diff --git a/android/build.gradle.kts b/android/build.gradle.kts index c0531bb2fe..26e3894c5a 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -127,15 +127,17 @@ dependencies { } Modules.apply { - implementation(project(client.path)) - implementation(project(res.path)) - implementation(project(billing.path)) - implementation(project(ad.path)) - implementation(project(logmob.path)) - implementation(project(scopemob.path)) - implementation(project(basemob.path)) - implementation(project(analytics.path)) - - testImplementation(project(test.path)) + implementation(project(client)) + implementation(project(res)) + implementation(project(billing)) + implementation(project(ad)) + implementation(project(analytics)) + testImplementation(project(test)) + } + + Modules.Submodules.apply { + implementation(project(logmob)) + implementation(project(scopemob)) + implementation(project(basemob)) } } diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index 8f0c08592f..14f6c7a043 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -41,10 +41,8 @@ kotlin { implementation(koinKtor) } - Modules.apply { - implementation(project(common.path)) - implementation(project(logmob.path)) - } + implementation(project(Modules.common)) + implementation(project(Modules.Submodules.logmob)) } } @@ -54,7 +52,7 @@ kotlin { implementation(mockative) implementation(coroutinesTest) } - implementation(project(Modules.test.path)) + implementation(project(Modules.test)) } } } diff --git a/billing/build.gradle.kts b/billing/build.gradle.kts index ca46a47d77..590ce1f8fe 100644 --- a/billing/build.gradle.kts +++ b/billing/build.gradle.kts @@ -51,8 +51,8 @@ dependencies { } } - Modules.apply { - implementation(project(logmob.path)) - implementation(project(scopemob.path)) + Modules.Submodules.apply { + implementation(project(logmob)) + implementation(project(scopemob)) } } diff --git a/buildSrc/src/main/kotlin/Modules.kt b/buildSrc/src/main/kotlin/Modules.kt index dedf3d3a63..e8709a30ec 100644 --- a/buildSrc/src/main/kotlin/Modules.kt +++ b/buildSrc/src/main/kotlin/Modules.kt @@ -1,27 +1,28 @@ object Modules { - val android = Module("android") - val ios = Module("ios") - val backend = Module("backend") + const val android = ":android" + const val ios = ":ios" + const val backend = ":backend" - val client = Module("client") - val res = Module("res") - val common = Module("common") - val billing = Module("billing") - val ad = Module("ad") - val analytics = Module("analytics") - val config = Module("config") - val test = Module("test") - val provider = Module("provider") + const val client = ":client" + const val res = ":res" + const val common = ":common" + const val billing = ":billing" + const val ad = ":ad" + const val analytics = ":analytics" + const val config = ":config" + const val test = ":test" + const val provider = ":provider" - // sub modules - val logmob = Module("logmob") - val scopemob = Module("scopemob") - val basemob = Module("basemob") - val parsermob = Module("parsermob") - - class Module(name: String) { - val path = ":$name" - val packageName = "${ProjectSettings.PROJECT_ID}${path.replace(":", ".")}" - val frameworkName = path.split(":").joinToString("") { it.capitalize() } + object Submodules { + const val logmob = ":submodule:logmob" + const val scopemob = ":submodule:scopemob" + const val basemob = ":submodule:basemob" + const val parsermob = ":submodule:parsermob" } } + +val String.packageName: String + get() = "${ProjectSettings.PROJECT_ID}${replace(":", ".")}" + +val String.frameworkName: String + get() = split(":").joinToString("") { it.capitalize() } diff --git a/client/build.gradle.kts b/client/build.gradle.kts index 090c4b12aa..dcffe7b317 100644 --- a/client/build.gradle.kts +++ b/client/build.gradle.kts @@ -35,12 +35,14 @@ kotlin { implementation(multiplatformSettings) } Modules.apply { - implementation(project(common.path)) - implementation(project(config.path)) - implementation(project(logmob.path)) - implementation(project(scopemob.path)) - implementation(project(parsermob.path)) - implementation(project(analytics.path)) + implementation(project(common)) + implementation(project(config)) + implementation(project(analytics)) + } + Modules.Submodules.apply { + implementation(project(logmob)) + implementation(project(scopemob)) + implementation(project(parsermob)) } } } @@ -50,7 +52,7 @@ kotlin { implementation(mockative) implementation(coroutinesTest) } - implementation(project(Modules.test.path)) + implementation(project(Modules.test)) } } diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 5c49c32007..0d2ec18ef4 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -43,7 +43,7 @@ kotlin { implementation(sqlDelightCoroutinesExt) implementation(coroutines) } - implementation(project(Modules.logmob.path)) + implementation(project(Modules.Submodules.logmob)) } } val commonTest by getting { @@ -52,7 +52,7 @@ kotlin { implementation(mockative) implementation(coroutinesTest) } - implementation(project(Modules.test.path)) + implementation(project(Modules.test)) } } diff --git a/config/build.gradle.kts b/config/build.gradle.kts index 188a692b42..103b4af945 100644 --- a/config/build.gradle.kts +++ b/config/build.gradle.kts @@ -23,12 +23,12 @@ kotlin { implementation(ktorJson) implementation(koinCore) } - implementation(project(Modules.logmob.path)) + implementation(project(Modules.Submodules.logmob)) } } val commonTest by getting { dependencies { - implementation(project(Modules.test.path)) + implementation(project(Modules.test)) } } diff --git a/provider/build.gradle.kts b/provider/build.gradle.kts index 64b7bbbcc9..970f812d68 100644 --- a/provider/build.gradle.kts +++ b/provider/build.gradle.kts @@ -22,8 +22,8 @@ kotlin { framework { Modules.apply { baseName = provider.frameworkName - export(project(client.path)) - export(project(analytics.path)) + export(project(client)) + export(project(analytics)) } } } @@ -42,10 +42,10 @@ kotlin { implementation(libs.common.koinCore) Modules.apply { - implementation(project(logmob.path)) - api(project(client.path)) - api(project(analytics.path)) + api(project(client)) + api(project(analytics)) } + implementation(project(Modules.Submodules.logmob)) } } val iosX64Test by getting diff --git a/res/build.gradle.kts b/res/build.gradle.kts index 4fc7a7e04f..1aed84b1f7 100644 --- a/res/build.gradle.kts +++ b/res/build.gradle.kts @@ -36,7 +36,7 @@ kotlin { } val commonTest by getting { dependencies { - implementation(project(Modules.test.path)) + implementation(project(Modules.test)) } } diff --git a/settings.gradle.kts b/settings.gradle.kts index a2380470bb..2f1d7f6865 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -44,13 +44,13 @@ include( ":ad", // android only ad module // submodules - ":logmob", // KMP, logger library - ":scopemob", // KMP, hand scope functions - ":basemob", // android only - ":parsermob" // KMP, parsing library + ":submodule:logmob", // KMP, logger library + ":submodule:scopemob", // KMP, hand scope functions + ":submodule:basemob", // android only + ":submodule:parsermob" // KMP, parsing library ) -project(":logmob").projectDir = file("submodule/logmob/logmob") -project(":scopemob").projectDir = file("submodule/scopemob/scopemob") -project(":basemob").projectDir = file("submodule/basemob/basemob") -project(":parsermob").projectDir = file("submodule/parsermob/parsermob") +project(":submodule:logmob").projectDir = file("submodule/logmob/logmob") +project(":submodule:scopemob").projectDir = file("submodule/scopemob/scopemob") +project(":submodule:basemob").projectDir = file("submodule/basemob/basemob") +project(":submodule:parsermob").projectDir = file("submodule/parsermob/parsermob") diff --git a/test/build.gradle.kts b/test/build.gradle.kts index d2020e0692..00d5de3979 100644 --- a/test/build.gradle.kts +++ b/test/build.gradle.kts @@ -25,7 +25,7 @@ kotlin { api(testAnnotations) implementation(coroutinesTest) } - implementation(project(Modules.logmob.path)) + implementation(project(Modules.Submodules.logmob)) } } val commonTest by getting