Skip to content

Commit

Permalink
[#1705] Create Submodules structure for Git submodules (#1714)
Browse files Browse the repository at this point in the history
* [#1705] Create Submodules structure for Git submodules

* [#1705] Create Submodules structure for Git submodules

* [#1705] Create Submodules structure for Git submodules
  • Loading branch information
mustafaozhan authored Jan 16, 2023
1 parent 837fc7a commit ab06f86
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 68 deletions.
2 changes: 1 addition & 1 deletion ad/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ dependencies {
@Suppress("UnstableApiUsage")
DeviceFlavour.googleImplementation(libs.android.google.admob)

implementation(project(Modules.logmob.path))
implementation(project(Modules.Submodules.logmob))
}
2 changes: 1 addition & 1 deletion analytics/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ kotlin {
}
val commonTest by getting {
dependencies {
implementation(project(Modules.test.path))
implementation(project(Modules.test))
}
}

Expand Down
22 changes: 12 additions & 10 deletions android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
8 changes: 3 additions & 5 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand All @@ -54,7 +52,7 @@ kotlin {
implementation(mockative)
implementation(coroutinesTest)
}
implementation(project(Modules.test.path))
implementation(project(Modules.test))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions billing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ dependencies {
}
}

Modules.apply {
implementation(project(logmob.path))
implementation(project(scopemob.path))
Modules.Submodules.apply {
implementation(project(logmob))
implementation(project(scopemob))
}
}
45 changes: 23 additions & 22 deletions buildSrc/src/main/kotlin/Modules.kt
Original file line number Diff line number Diff line change
@@ -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() }
16 changes: 9 additions & 7 deletions client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
}
Expand All @@ -50,7 +52,7 @@ kotlin {
implementation(mockative)
implementation(coroutinesTest)
}
implementation(project(Modules.test.path))
implementation(project(Modules.test))
}
}

Expand Down
4 changes: 2 additions & 2 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ kotlin {
implementation(sqlDelightCoroutinesExt)
implementation(coroutines)
}
implementation(project(Modules.logmob.path))
implementation(project(Modules.Submodules.logmob))
}
}
val commonTest by getting {
Expand All @@ -52,7 +52,7 @@ kotlin {
implementation(mockative)
implementation(coroutinesTest)
}
implementation(project(Modules.test.path))
implementation(project(Modules.test))
}
}

Expand Down
4 changes: 2 additions & 2 deletions config/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down
10 changes: 5 additions & 5 deletions provider/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion res/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ kotlin {
}
val commonTest by getting {
dependencies {
implementation(project(Modules.test.path))
implementation(project(Modules.test))
}
}

Expand Down
16 changes: 8 additions & 8 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
2 changes: 1 addition & 1 deletion test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ kotlin {
api(testAnnotations)
implementation(coroutinesTest)
}
implementation(project(Modules.logmob.path))
implementation(project(Modules.Submodules.logmob))
}
}
val commonTest by getting
Expand Down

0 comments on commit ab06f86

Please sign in to comment.