diff --git a/build-conventions/src/main/kotlin/convention.mpp.gradle.kts b/build-conventions/src/main/kotlin/convention.mpp.gradle.kts index 641b5d0..9a0815e 100644 --- a/build-conventions/src/main/kotlin/convention.mpp.gradle.kts +++ b/build-conventions/src/main/kotlin/convention.mpp.gradle.kts @@ -1,4 +1,4 @@ -import util.sharedTestDependencies +import util.sharedTest import util.targetGroup plugins { @@ -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 { diff --git a/build-conventions/src/main/kotlin/convention.publishing-mpp.gradle.kts b/build-conventions/src/main/kotlin/convention.publishing-mpp.gradle.kts index b581120..9a51ad6 100644 --- a/build-conventions/src/main/kotlin/convention.publishing-mpp.gradle.kts +++ b/build-conventions/src/main/kotlin/convention.publishing-mpp.gradle.kts @@ -15,12 +15,12 @@ kotlin { publications { matching { it.name in this@onlyPublishIf.names }.all { val targetPublication = this@all - tasks.withType() - .matching { it.publication == targetPublication } - .all { onlyIf(enabled) } - tasks.withType() - .matching { it.publication.orNull == targetPublication } - .all { onlyIf(enabled) } + tasks { + withType() + .all { onlyIf { publication != targetPublication || enabled(this) } } + withType() + .all { onlyIf { publication.orNull != targetPublication || enabled(this) } } + } } } } @@ -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() - 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" }) diff --git a/build-conventions/src/main/kotlin/util/KotlinTargetDetails.kt b/build-conventions/src/main/kotlin/util/KotlinTargetDetails.kt index 3f10a9d..50febc5 100644 --- a/build-conventions/src/main/kotlin/util/KotlinTargetDetails.kt +++ b/build-conventions/src/main/kotlin/util/KotlinTargetDetails.kt @@ -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 } diff --git a/build-conventions/src/main/kotlin/util/targetGroup.kt b/build-conventions/src/main/kotlin/util/targetGroup.kt index a23dea6..a643aa5 100644 --- a/build-conventions/src/main/kotlin/util/targetGroup.kt +++ b/build-conventions/src/main/kotlin/util/targetGroup.kt @@ -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 @@ -32,29 +31,27 @@ fun NamedDomainObjectContainer.withName(name: String, action: A matching { it.name == name }.all(action) } -private fun NamedDomainObjectContainer.sharedDependencies( +private fun NamedDomainObjectContainer.sharedSourceSets( sourceSets: List, - action: Action, + action: Action, ) { sourceSets.forEach { - withName(it) { - dependencies { action.execute(this) } - } + withName(it, action) } } -fun NamedDomainObjectContainer.sharedMainDependencies(action: Action) { - sharedDependencies(listOf("sharedMain", "androidMain"), action) +fun NamedDomainObjectContainer.sharedMain(action: Action) { + sharedSourceSets(listOf("sharedMain", "androidMain"), action) } -fun NamedDomainObjectContainer.sharedTestDependencies(action: Action) { - sharedDependencies(listOf("sharedTest", "androidTest"), action) +fun NamedDomainObjectContainer.sharedTest(action: Action) { + sharedSourceSets(listOf("sharedTest", "androidTest"), action) } -fun NamedDomainObjectContainer.blockingMainDependencies(action: Action) { - sharedDependencies(listOf("blockingMain", "androidMain"), action) +fun NamedDomainObjectContainer.blockingMain(action: Action) { + sharedSourceSets(listOf("blockingMain", "androidMain"), action) } -fun NamedDomainObjectContainer.blockingTestDependencies(action: Action) { - sharedDependencies(listOf("blockingTest", "androidTest"), action) +fun NamedDomainObjectContainer.blockingTest(action: Action) { + sharedSourceSets(listOf("blockingTest", "androidTest"), action) } diff --git a/gradle.properties b/gradle.properties index 85065b7..fd476d4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,7 +22,7 @@ gh.owner.email=martynas@petuska.dev #======================================= 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 diff --git a/library/klip-assertions/build.gradle.kts b/library/klip-assertions/build.gradle.kts index c1e3798..bf0e9b3 100644 --- a/library/klip-assertions/build.gradle.kts +++ b/library/klip-assertions/build.gradle.kts @@ -1,4 +1,4 @@ -import util.blockingMainDependencies +import util.blockingMain plugins { id("convention.library-mpp") @@ -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:_") + } } } } diff --git a/library/klip-core/build.gradle.kts b/library/klip-core/build.gradle.kts index 2681622..4b2b061 100644 --- a/library/klip-core/build.gradle.kts +++ b/library/klip-core/build.gradle.kts @@ -1,4 +1,4 @@ -import util.sharedMainDependencies +import util.sharedMain plugins { kotlin("plugin.serialization") @@ -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 { diff --git a/library/klip-runner/build.gradle.kts b/library/klip-runner/build.gradle.kts index 7ad299b..5b39f94 100644 --- a/library/klip-runner/build.gradle.kts +++ b/library/klip-runner/build.gradle.kts @@ -1,4 +1,4 @@ -import util.sharedMainDependencies +import util.sharedMain plugins { id("convention.library-mpp") @@ -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 {