Skip to content

Commit

Permalink
Kotlin 1.9.20: new target hierarchy setup, opt in to 'expect'/'actual…
Browse files Browse the repository at this point in the history
…' classes (#193)

🎉🎉🎉🎉
  • Loading branch information
hoc081098 authored Nov 11, 2023
1 parent a599a4b commit 0238282
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 123 deletions.
148 changes: 28 additions & 120 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithTests
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
import java.net.URL
Expand Down Expand Up @@ -60,22 +61,18 @@ kotlin {
}
}
browser {
testTask(
Action {
useMocha {
timeout = "10s"
}
},
)
testTask {
useMocha {
timeout = "10s"
}
}
}
nodejs {
testTask(
Action {
useMocha {
timeout = "10s"
}
},
)
testTask {
useMocha {
timeout = "10s"
}
}
}
}

Expand Down Expand Up @@ -107,130 +104,28 @@ kotlin {
androidNativeX64()

sourceSets {
val commonMain by getting {
commonMain {
dependencies {
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
}
}
val commonTest by getting {
commonTest {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion")
}
}
val jvmMain by getting {
dependsOn(commonMain)
}
val jvmTest by getting {
dependsOn(commonTest)

jvmTest {
dependencies {
implementation(kotlin("test-junit"))
}
}
val jsMain by getting {
dependsOn(commonMain)
}
val jsTest by getting {
jsTest {
dependencies {
implementation(kotlin("test-js"))
}
}

val nativeMain by creating {
dependsOn(commonMain)
}
val nativeTest by creating {
dependsOn(commonTest)
}

val darwinMain by creating {
dependsOn(nativeMain)
}
val darwinTest by creating {
dependsOn(nativeTest)
}

val linuxMain by creating {
dependsOn(nativeMain)
}
val linuxTest by creating {
dependsOn(nativeTest)
}

val pthreadAndroidMain by creating {
dependsOn(nativeMain)
}
val pthreadAndroidTest by creating {
dependsOn(nativeTest)
}

val appleTargets =
listOf(
"iosX64",
"iosSimulatorArm64",
"iosArm64",
"macosX64",
"macosArm64",
"tvosArm64",
"tvosX64",
"tvosSimulatorArm64",
"watchosArm32",
"watchosArm64",
"watchosSimulatorArm64",
"watchosX64",
"watchosSimulatorArm64",
"watchosDeviceArm64",
)

val linuxTargets =
listOf(
"linuxX64",
"linuxArm64",
)

val androidNativeTargets =
listOf(
"androidNativeArm32",
"androidNativeArm64",
"androidNativeX86",
"androidNativeX64",
)

appleTargets.forEach {
getByName("${it}Main") {
dependsOn(darwinMain)
}
getByName("${it}Test") {
dependsOn(darwinTest)
}
}

linuxTargets.forEach {
getByName("${it}Main") {
dependsOn(linuxMain)
}
getByName("${it}Test") {
dependsOn(linuxTest)
}
}

androidNativeTargets.forEach {
getByName("${it}Main") {
dependsOn(pthreadAndroidMain)
}
getByName("${it}Test") {
dependsOn(pthreadAndroidTest)
}
}

getByName("mingwX64Main") {
dependsOn(nativeMain)
}
getByName("mingwX64Test") {
dependsOn(nativeTest)
}
}

// enable running ios tests on a background thread as well
Expand All @@ -250,6 +145,19 @@ kotlin {
}
}

tasks.withType<KotlinCompile<*>>().configureEach {

This comment has been minimized.

Copy link
@hoangchungk53qx1

hoangchungk53qx1 Nov 11, 2023

Contributor

🙏

kotlinOptions {
// 'expect'/'actual' classes (including interfaces, objects, annotations, enums,
// and 'actual' typealiases) are in Beta.
// You can use -Xexpect-actual-classes flag to suppress this warning.
// Also see: https://youtrack.jetbrains.com/issue/KT-61573
freeCompilerArgs +=
listOf(
"-Xexpect-actual-classes",
)
}
}

spotless {
kotlin {
target("**/*.kt")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import kotlinx.coroutines.flow.take

private data class MyTuple2<A, B>(val first: A, val second: B)

@Suppress("NOTHING_TO_INLINE")
private inline infix fun <A, B> A.with(second: B) = MyTuple2(this, second)

@ExperimentalCoroutinesApi
Expand Down
3 changes: 0 additions & 3 deletions src/commonTest/kotlin/com/hoc081098/flowext/SelectorsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ package com.hoc081098.flowext

import com.hoc081098.flowext.utils.BaseTest
import com.hoc081098.flowext.utils.test
import kotlin.native.concurrent.SharedImmutable
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand Down Expand Up @@ -73,10 +72,8 @@ private fun <T, R> Flow<T>.scanSkipFirst(
operation: suspend (acc: R, value: T) -> R,
): Flow<R> = scan(initial, operation).drop(1)

@SharedImmutable
private val zeroToTen = List(10) { it.toString() }

@SharedImmutable
private val reducer: (acc: State, value: Int) -> State = { state, action ->
when (action) {
// items
Expand Down

1 comment on commit 0238282

@hoc081098
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hoangchungk53qx1 lên bạn ơi

Sent from my 2201117TG using FastHub

Please sign in to comment.