Skip to content

Commit

Permalink
INIT
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetuska committed Jun 18, 2022
1 parent 1ba7222 commit c5f9ec4
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 71 deletions.
12 changes: 7 additions & 5 deletions build-conventions/src/main/kotlin/convention.mpp.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import util.sharedTestDependencies
import util.sharedTest
import util.targetGroup

plugins {
Expand Down Expand Up @@ -70,10 +70,12 @@ kotlin {
implementation(kotlin("test-annotations-common"))
}
}
sharedTestDependencies {
// implementation("io.kotest:kotest-assertions-core:_")
// implementation("io.kotest:kotest-property:_")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:_")
sharedTest {
dependencies {
implementation("io.kotest:kotest-assertions-core:_")
implementation("io.kotest:kotest-property:_")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:_")
}
}
named("jsTest") {
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ kotlin {
publications {
matching { it.name in this@onlyPublishIf.names }.all {
val targetPublication = this@all
tasks.withType<AbstractPublishToMaven>()
.matching { it.publication == targetPublication }
.all { onlyIf(enabled) }
tasks.withType<GenerateModuleMetadata>()
.matching { it.publication.orNull == targetPublication }
.all { onlyIf(enabled) }
tasks {
withType<AbstractPublishToMaven>()
.all { onlyIf { publication != targetPublication || enabled(this) } }
withType<GenerateModuleMetadata>()
.all { onlyIf { publication.orNull != targetPublication || enabled(this) } }
}
}
}
}
Expand All @@ -32,11 +32,6 @@ kotlin {
val osxHostTargets = nativeTargets.matching { it.konanTarget.buildHost == Family.OSX }
val mainHostTargets = targets.matching { it !in nativeTargets }
val androidTargets = targets.withType<KotlinAndroidTarget>()
logger.info("Linux host targets: $linuxHostTargets")
logger.info("OSX host targets: $osxHostTargets")
logger.info("Windows host targets: $windowsHostTargets")
logger.info("Main host targets: $mainHostTargets")
logger.info("Android targets: $androidTargets")
val mpp = objects.domainObjectContainer(Named::class.java)
mpp.add(Named { "kotlinMultiplatform" })

Expand Down
39 changes: 10 additions & 29 deletions build-conventions/src/main/kotlin/util/KotlinTargetDetails.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,16 @@ import org.jetbrains.kotlin.konan.target.Family
import org.jetbrains.kotlin.konan.target.KonanTarget

val KonanTarget.buildHost: Family
get() = when (this) {
KonanTarget.WASM32,
KonanTarget.ANDROID_X64,
KonanTarget.ANDROID_X86,
KonanTarget.ANDROID_ARM32,
KonanTarget.ANDROID_ARM64,
KonanTarget.LINUX_ARM64,
KonanTarget.LINUX_ARM32_HFP,
KonanTarget.LINUX_MIPS32,
KonanTarget.LINUX_MIPSEL32,
KonanTarget.LINUX_X64 -> Family.LINUX
get() = when (family) {
Family.OSX,
Family.IOS,
Family.TVOS,
Family.WATCHOS -> Family.OSX

KonanTarget.MINGW_X86,
KonanTarget.MINGW_X64 -> Family.MINGW
Family.ANDROID,
Family.ZEPHYR,
Family.WASM,
Family.LINUX -> Family.LINUX

KonanTarget.IOS_ARM32,
KonanTarget.IOS_ARM64,
KonanTarget.IOS_X64,
KonanTarget.IOS_SIMULATOR_ARM64,
KonanTarget.WATCHOS_ARM32,
KonanTarget.WATCHOS_ARM64,
KonanTarget.WATCHOS_X86,
KonanTarget.WATCHOS_X64,
KonanTarget.WATCHOS_SIMULATOR_ARM64,
KonanTarget.TVOS_ARM64,
KonanTarget.TVOS_X64,
KonanTarget.TVOS_SIMULATOR_ARM64,
KonanTarget.MACOS_X64,
KonanTarget.MACOS_ARM64 -> Family.OSX

is KonanTarget.ZEPHYR -> throw IllegalStateException("Target $this not supported")
Family.MINGW -> Family.MINGW
}
25 changes: 11 additions & 14 deletions build-conventions/src/main/kotlin/util/targetGroup.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import org.gradle.api.NamedDomainObjectContainer
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.invoke
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget

Expand All @@ -32,29 +31,27 @@ fun NamedDomainObjectContainer<KotlinSourceSet>.withName(name: String, action: A
matching { it.name == name }.all(action)
}

private fun NamedDomainObjectContainer<KotlinSourceSet>.sharedDependencies(
private fun NamedDomainObjectContainer<KotlinSourceSet>.sharedSourceSets(
sourceSets: List<String>,
action: Action<KotlinDependencyHandler>,
action: Action<KotlinSourceSet>,
) {
sourceSets.forEach {
withName(it) {
dependencies { action.execute(this) }
}
withName(it, action)
}
}

fun NamedDomainObjectContainer<KotlinSourceSet>.sharedMainDependencies(action: Action<KotlinDependencyHandler>) {
sharedDependencies(listOf("sharedMain", "androidMain"), action)
fun NamedDomainObjectContainer<KotlinSourceSet>.sharedMain(action: Action<KotlinSourceSet>) {
sharedSourceSets(listOf("sharedMain", "androidMain"), action)
}

fun NamedDomainObjectContainer<KotlinSourceSet>.sharedTestDependencies(action: Action<KotlinDependencyHandler>) {
sharedDependencies(listOf("sharedTest", "androidTest"), action)
fun NamedDomainObjectContainer<KotlinSourceSet>.sharedTest(action: Action<KotlinSourceSet>) {
sharedSourceSets(listOf("sharedTest", "androidTest"), action)
}

fun NamedDomainObjectContainer<KotlinSourceSet>.blockingMainDependencies(action: Action<KotlinDependencyHandler>) {
sharedDependencies(listOf("blockingMain", "androidMain"), action)
fun NamedDomainObjectContainer<KotlinSourceSet>.blockingMain(action: Action<KotlinSourceSet>) {
sharedSourceSets(listOf("blockingMain", "androidMain"), action)
}

fun NamedDomainObjectContainer<KotlinSourceSet>.blockingTestDependencies(action: Action<KotlinDependencyHandler>) {
sharedDependencies(listOf("blockingTest", "androidTest"), action)
fun NamedDomainObjectContainer<KotlinSourceSet>.blockingTest(action: Action<KotlinSourceSet>) {
sharedSourceSets(listOf("blockingTest", "androidTest"), action)
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ [email protected]
#======================================= Project ========================================
group=dev.petuska
description=Kotlin Multiplatform test snapshots (klips) manager
version=0.0.0
version=0.4.0-SNAPSHOT
#======================================== Build =========================================
kotlin.js.test.browser=firefox-headless
# linux | macos | windows
Expand Down
8 changes: 5 additions & 3 deletions library/klip-assertions/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import util.blockingMainDependencies
import util.blockingMain

plugins {
id("convention.library-mpp")
Expand All @@ -16,8 +16,10 @@ kotlin {
implementation(project(":library:klip-core"))
}
}
blockingMainDependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:_")
blockingMain {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:_")
}
}
}
}
12 changes: 7 additions & 5 deletions library/klip-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import util.sharedMainDependencies
import util.sharedMain

plugins {
kotlin("plugin.serialization")
Expand All @@ -15,10 +15,12 @@ kotlin {
api(project(":library:klip-api"))
}
}
sharedMainDependencies {
implementation("io.ktor:ktor-client-core:_")
implementation("io.ktor:ktor-serialization-kotlinx-json:_")
implementation("io.ktor:ktor-client-content-negotiation:_")
sharedMain {
dependencies {
implementation("io.ktor:ktor-client-core:_")
implementation("io.ktor:ktor-serialization-kotlinx-json:_")
implementation("io.ktor:ktor-client-content-negotiation:_")
}
}

configureEach {
Expand Down
8 changes: 5 additions & 3 deletions library/klip-runner/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import util.sharedMainDependencies
import util.sharedMain

plugins {
id("convention.library-mpp")
Expand All @@ -9,8 +9,10 @@ description = "Kotlin multiplatform snapshot (klip) testing. Common test runner.

kotlin {
sourceSets {
sharedMainDependencies {
api("org.jetbrains.kotlinx:kotlinx-coroutines-test:_")
sharedMain {
dependencies {
api("org.jetbrains.kotlinx:kotlinx-coroutines-test:_")
}
}
named("stubMain") {
dependencies {
Expand Down

0 comments on commit c5f9ec4

Please sign in to comment.