Skip to content

Commit

Permalink
Move commonAppleJvmMain to "concurrent" and make it common
Browse files Browse the repository at this point in the history
  • Loading branch information
BoD committed Aug 17, 2023
1 parent 7295310 commit 0bae9cf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
21 changes: 16 additions & 5 deletions build-logic/src/main/kotlin/Mpp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ fun Project.configureMpp(
* Current Graph is something like so
*
* graph TB
* commonMain --> jvmMain
* commonMain --> appleMain
* commonMain --> concurrentMain
* commonMain --> linuxMain
* commonMain --> jsMain
* concurrentMain --> jvmMain
* concurrentMain --> appleMain
* appleMain --> macosX64
* appleMain --> macosArm64
* appleMain --> iosArm64
Expand Down Expand Up @@ -177,12 +178,22 @@ private fun KotlinMultiplatformExtension.configureSourceSetGraph() {
val hasAppleTarget = targets.any {
it is KotlinNativeTarget && it.konanTarget.family in setOf(Family.IOS, Family.OSX, Family.WATCHOS, Family.TVOS)
}

val concurrentMain = sourceSets.create("concurrentMain")
val concurrentTest = sourceSets.create("concurrentTest")

concurrentMain.dependsOn(sourceSets.getByName("commonMain"))
concurrentTest.dependsOn(sourceSets.getByName("commonTest"))

sourceSets.findByName("jvmMain")?.dependsOn(concurrentMain)
sourceSets.findByName("jvmTest")?.dependsOn(concurrentTest)

if (hasAppleTarget) {
val appleMain = sourceSets.create("appleMain")
val appleTest = sourceSets.create("appleTest")

appleMain.dependsOn(sourceSets.getByName("commonMain"))
appleTest.dependsOn(sourceSets.getByName("commonTest"))
appleMain.dependsOn(concurrentMain)
appleTest.dependsOn(concurrentTest)

allAppleTargets.forEach {
sourceSets.findByName("${it}Main")?.dependsOn(appleMain)
Expand Down Expand Up @@ -240,4 +251,4 @@ fun Project.registerJavaCodegenTestTask() {
}

tasks.named("build").dependsOn(task)
}
}
21 changes: 6 additions & 15 deletions libraries/apollo-mockserver/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,13 @@ kotlin {
}
}
}
}

val commonAppleJvmMain = sourceSets.create("commonAppleJvmMain").apply {
dependsOn(sourceSets.getByName("commonMain"))
dependencies {
implementation(libs.ktor.server.core)
implementation(libs.ktor.server.cio)
implementation(libs.ktor.server.websockets)
findByName("concurrentMain")?.apply {
dependencies {
implementation(libs.ktor.server.core)
implementation(libs.ktor.server.cio)
implementation(libs.ktor.server.websockets)
}
}
}
val commonAppleJvmTest = sourceSets.create("commonAppleJvmTest").apply {
dependsOn(sourceSets.getByName("commonTest"))
}
sourceSets.getByName("jvmMain").dependsOn(commonAppleJvmMain)
sourceSets.getByName("jvmTest").dependsOn(commonAppleJvmTest)
sourceSets.getByName("appleMain").dependsOn(commonAppleJvmMain)
sourceSets.getByName("appleTest").dependsOn(commonAppleJvmTest)
}

0 comments on commit 0bae9cf

Please sign in to comment.