Skip to content

Commit

Permalink
Upgrade to Kotlin 2.1.0
Browse files Browse the repository at this point in the history
* Avoid using deprecated API when grouping source sets together
* Do not explicitly set `metaInfo = true` for NPM, it's the default
* Upgrade the Yarn lock file
  • Loading branch information
dkhalanskyjb committed Jan 23, 2025
1 parent b289d0b commit 7757d36
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 246 deletions.
167 changes: 67 additions & 100 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import java.io.ByteArrayOutputStream
import java.io.PrintWriter
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.konan.target.Family

plugins {
Expand All @@ -32,58 +33,54 @@ java {
toolchain { languageVersion.set(JavaLanguageVersion.of(mainJavaToolchainVersion)) }
}

kotlin {
explicitApi()

infra {
common("tzfile") {
// Tiers are in accordance with <https://kotlinlang.org/docs/native-target-support.html>
common("tzdbOnFilesystem") {
common("linux") {
// Tier 1
target("linuxX64")
// Tier 2
target("linuxArm64")
// Tier 4 (deprecated, but still in demand)
target("linuxArm32Hfp")
}
common("darwin") {
common("darwinDevices") {
// Tier 1
target("macosX64")
target("macosArm64")
// Tier 2
target("watchosX64")
target("watchosArm32")
target("watchosArm64")
target("tvosX64")
target("tvosArm64")
target("iosArm64")
// Tier 3
target("watchosDeviceArm64")
}
common("darwinSimulator") {
// Tier 1
target("iosSimulatorArm64")
target("iosX64")
// Tier 2
target("watchosSimulatorArm64")
target("tvosSimulatorArm64")
}
}
fun NamedDomainObjectContainer<KotlinSourceSet>.groupSourceSets(
groupName: String,
reverseDependencies: List<String>,
dependencies: List<String> = emptyList(),
) {
val sourceSetSuffixes = listOf("Main", "Test")
for (suffix in sourceSetSuffixes) {
register(groupName + suffix) {
for (dep in dependencies) {
dependsOn(get(dep + suffix))
}
common("androidNative") {
target("androidNativeArm32")
target("androidNativeArm64")
target("androidNativeX86")
target("androidNativeX64")
for (revDep in reverseDependencies) {
get(revDep + suffix).dependsOn(this)
}
}
// Tier 3
common("windows") {
target("mingwX64")
}
}
}


kotlin {
explicitApi()

// Tiers are in accordance with <https://kotlinlang.org/docs/native-target-support.html>
// Tier 1
macosX64()
macosArm64()
iosSimulatorArm64()
iosX64()
iosArm64()
// Tier 2
linuxX64()
linuxArm64()
watchosSimulatorArm64()
watchosX64()
watchosArm32()
watchosArm64()
tvosSimulatorArm64()
tvosX64()
tvosArm64()
// Tier 3
androidNativeArm32()
androidNativeArm64()
androidNativeX86()
androidNativeX64()
mingwX64()
watchosDeviceArm64()
// Deprecated
@Suppress("DEPRECATION") linuxArm32Hfp()

jvm {
attributes {
Expand All @@ -107,7 +104,6 @@ kotlin {
kotlinOptions {
sourceMap = true
moduleKind = "umd"
metaInfo = true
}
}
// compilations["main"].apply {
Expand Down Expand Up @@ -161,7 +157,26 @@ kotlin {
}
}
}

sourceSets {
groupSourceSets("linux", listOf("linuxX64", "linuxArm64", "linuxArm32Hfp"))
groupSourceSets("darwinDevices", listOf(
"macosX64", "macosArm64", "watchosX64", "watchosArm32", "watchosArm64", "tvosX64", "tvosArm64", "iosArm64",
"watchosDeviceArm64"
))
groupSourceSets("darwinSimulator",
listOf("iosSimulatorArm64", "iosX64", "watchosSimulatorArm64", "tvosSimulatorArm64")
)
groupSourceSets("darwin", listOf("darwinDevices", "darwinSimulator"))
groupSourceSets("tzdbOnFilesystem", listOf("linux", "darwin"))
groupSourceSets("androidNative",
listOf("androidNativeArm32", "androidNativeArm64", "androidNativeX86", "androidNativeX64")
)
groupSourceSets("tzfile", listOf("tzdbOnFilesystem", "androidNative"), listOf("native"))
groupSourceSets("windows", listOf("mingwX64"), listOf("native"))
groupSourceSets("commonJs", listOf("js", "wasmJs"), listOf("common"))
groupSourceSets("commonKotlin", listOf("native", "wasmWasi"), listOf("common"))

commonMain {
dependencies {
compileOnly("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion")
Expand All @@ -174,78 +189,30 @@ kotlin {
}
}

val jvmMain by getting {
}

val jvmTest by getting {
}

val commonJsMain by creating {
dependsOn(commonMain.get())
val commonJsMain by getting {
dependencies {
api("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion")
implementation(npm("@js-joda/core", "3.2.0"))
}
}

val commonJsTest by creating {
dependsOn(commonTest.get())
val commonJsTest by getting {
dependencies {
implementation(npm("@js-joda/timezone", "2.3.0"))
}
}

val jsMain by getting {
dependsOn(commonJsMain)
}

val jsTest by getting {
dependsOn(commonJsTest)
}

val wasmJsMain by getting {
dependsOn(commonJsMain)
}

val wasmJsTest by getting {
dependsOn(commonJsTest)
}

val commonKotlinMain by creating {
dependsOn(commonMain.get())
val commonKotlinMain by getting {
dependencies {
api("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion")
}
}

val commonKotlinTest by creating {
dependsOn(commonTest.get())
}

val nativeMain by getting {
dependsOn(commonKotlinMain)
}

val nativeTest by getting {
dependsOn(commonKotlinTest)
}

val wasmWasiMain by getting {
dependsOn(commonKotlinMain)
}

val wasmWasiTest by getting {
dependsOn(commonKotlinTest)
dependencies {
runtimeOnly(project(":kotlinx-datetime-zoneinfo"))
}
}

val darwinMain by getting {
}

val darwinTest by getting {
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ versionSuffix=SNAPSHOT

tzdbVersion=2024a

defaultKotlinVersion=1.9.21
defaultKotlinVersion=2.1.0
dokkaVersion=1.9.20
serializationVersion=1.6.2
benchmarksVersion=0.7.2
Expand Down
Loading

0 comments on commit 7757d36

Please sign in to comment.