Skip to content

Commit 04b08a6

Browse files
authored
Upgrade to Kotlin 2.1.0 (#475)
* 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 * No longer use the -trw flag * Add .kotlin to .gitignore
1 parent 43adf1a commit 04b08a6

File tree

6 files changed

+196
-258
lines changed

6 files changed

+196
-258
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ target
66
build
77
/local.properties
88
benchmarks.jar
9+
.kotlin

core/build.gradle.kts

Lines changed: 74 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import java.io.ByteArrayOutputStream
66
import java.io.PrintWriter
77
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask
88
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
9+
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
910
import org.jetbrains.kotlin.konan.target.Family
1011

1112
plugins {
@@ -35,53 +36,50 @@ java {
3536
kotlin {
3637
explicitApi()
3738

38-
infra {
39-
common("tzfile") {
40-
// Tiers are in accordance with <https://kotlinlang.org/docs/native-target-support.html>
41-
common("tzdbOnFilesystem") {
42-
common("linux") {
43-
// Tier 1
44-
target("linuxX64")
45-
// Tier 2
46-
target("linuxArm64")
47-
// Tier 4 (deprecated, but still in demand)
48-
target("linuxArm32Hfp")
39+
@OptIn(ExperimentalKotlinGradlePluginApi::class)
40+
applyDefaultHierarchyTemplate {
41+
common {
42+
group("commonKotlin") {
43+
group("commonJs") {
44+
withJs()
45+
withWasmJs()
4946
}
50-
common("darwin") {
51-
common("darwinDevices") {
52-
// Tier 1
53-
target("macosX64")
54-
target("macosArm64")
55-
// Tier 2
56-
target("watchosX64")
57-
target("watchosArm32")
58-
target("watchosArm64")
59-
target("tvosX64")
60-
target("tvosArm64")
61-
target("iosArm64")
62-
// Tier 3
63-
target("watchosDeviceArm64")
47+
withWasmWasi()
48+
group("native") {
49+
group("tzfile") {
50+
group("tzdbOnFilesystem") {
51+
group("linux") {
52+
withLinux()
53+
}
54+
group("darwin") {
55+
group("darwinDevices") {
56+
withMacosX64()
57+
withMacosArm64()
58+
withWatchosX64()
59+
withWatchosArm32()
60+
withWatchosArm64()
61+
withTvosX64()
62+
withTvosArm64()
63+
withIosArm64()
64+
withWatchosDeviceArm64()
65+
}
66+
group("darwinSimulator") {
67+
withIosSimulatorArm64()
68+
withIosX64()
69+
withWatchosSimulatorArm64()
70+
withTvosSimulatorArm64()
71+
}
72+
}
73+
}
74+
group("androidNative") {
75+
withAndroidNative()
76+
}
6477
}
65-
common("darwinSimulator") {
66-
// Tier 1
67-
target("iosSimulatorArm64")
68-
target("iosX64")
69-
// Tier 2
70-
target("watchosSimulatorArm64")
71-
target("tvosSimulatorArm64")
78+
group("windows") {
79+
withMingw()
7280
}
7381
}
7482
}
75-
common("androidNative") {
76-
target("androidNativeArm32")
77-
target("androidNativeArm64")
78-
target("androidNativeX86")
79-
target("androidNativeX64")
80-
}
81-
}
82-
// Tier 3
83-
common("windows") {
84-
target("mingwX64")
8583
}
8684
}
8785

@@ -107,7 +105,6 @@ kotlin {
107105
kotlinOptions {
108106
sourceMap = true
109107
moduleKind = "umd"
110-
metaInfo = true
111108
}
112109
}
113110
// compilations["main"].apply {
@@ -131,6 +128,33 @@ kotlin {
131128
nodejs()
132129
}
133130

131+
// Tiers are in accordance with <https://kotlinlang.org/docs/native-target-support.html>
132+
// Tier 1
133+
macosX64()
134+
macosArm64()
135+
iosSimulatorArm64()
136+
iosX64()
137+
iosArm64()
138+
// Tier 2
139+
linuxX64()
140+
linuxArm64()
141+
watchosSimulatorArm64()
142+
watchosX64()
143+
watchosArm32()
144+
watchosArm64()
145+
tvosSimulatorArm64()
146+
tvosX64()
147+
tvosArm64()
148+
// Tier 3
149+
androidNativeArm32()
150+
androidNativeArm64()
151+
androidNativeX86()
152+
androidNativeX64()
153+
mingwX64()
154+
watchosDeviceArm64()
155+
// Deprecated
156+
@Suppress("DEPRECATION") linuxArm32Hfp()
157+
134158
@OptIn(ExperimentalKotlinGradlePluginApi::class)
135159
compilerOptions {
136160
freeCompilerArgs.add("-Xexpect-actual-classes")
@@ -149,9 +173,6 @@ kotlin {
149173
}
150174

151175
targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
152-
compilations["test"].kotlinOptions {
153-
freeCompilerArgs += listOf("-trw")
154-
}
155176
if (konanTarget.family == Family.MINGW) {
156177
compilations["test"].cinterops {
157178
create("modern_api") {
@@ -161,6 +182,7 @@ kotlin {
161182
}
162183
}
163184
}
185+
164186
sourceSets {
165187
commonMain {
166188
dependencies {
@@ -174,78 +196,30 @@ kotlin {
174196
}
175197
}
176198

177-
val commonKotlinMain by creating {
178-
dependsOn(commonMain.get())
179-
dependencies {
180-
api("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion")
181-
}
182-
}
183-
184-
val commonKotlinTest by creating {
185-
dependsOn(commonTest.get())
186-
}
187-
188-
val jvmMain by getting {
189-
}
190-
191-
val jvmTest by getting {
192-
}
193-
194-
val commonJsMain by creating {
195-
dependsOn(commonKotlinMain)
199+
val commonJsMain by getting {
196200
dependencies {
197201
api("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion")
198202
implementation(npm("@js-joda/core", "3.2.0"))
199203
}
200204
}
201205

202-
val commonJsTest by creating {
203-
dependsOn(commonKotlinTest)
206+
val commonJsTest by getting {
204207
dependencies {
205208
implementation(npm("@js-joda/timezone", "2.3.0"))
206209
}
207210
}
208211

209-
val jsMain by getting {
210-
dependsOn(commonJsMain)
211-
}
212-
213-
val jsTest by getting {
214-
dependsOn(commonJsTest)
215-
}
216-
217-
val wasmJsMain by getting {
218-
dependsOn(commonJsMain)
219-
}
220-
221-
val wasmJsTest by getting {
222-
dependsOn(commonJsTest)
223-
}
224-
225-
val nativeMain by getting {
226-
dependsOn(commonKotlinMain)
227-
}
228-
229-
val nativeTest by getting {
230-
dependsOn(commonKotlinTest)
231-
}
232-
233-
val wasmWasiMain by getting {
234-
dependsOn(commonKotlinMain)
212+
val commonKotlinMain by getting {
213+
dependencies {
214+
api("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion")
215+
}
235216
}
236217

237218
val wasmWasiTest by getting {
238-
dependsOn(commonKotlinTest)
239219
dependencies {
240220
runtimeOnly(project(":kotlinx-datetime-zoneinfo"))
241221
}
242222
}
243-
244-
val darwinMain by getting {
245-
}
246-
247-
val darwinTest by getting {
248-
}
249223
}
250224
}
251225

core/jvm/src/LocalDate.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ public actual class LocalDate internal constructor(internal val value: jtLocalDa
8686
public actual fun toEpochDays(): Long = value.toEpochDay()
8787

8888
@PublishedApi
89-
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
90-
@LowPriorityInOverloadResolution
91-
internal fun toEpochDays(): Int = value.toEpochDay().clampToInt()
89+
@JvmName("toEpochDays")
90+
internal fun toEpochDaysJvm(): Int = value.toEpochDay().clampToInt()
9291
}
9392

9493
@Deprecated("Use the plus overload with an explicit number of units", ReplaceWith("this.plus(1, unit)"))
@@ -156,9 +155,8 @@ public actual fun LocalDate.until(other: LocalDate, unit: DateTimeUnit.DateBased
156155
}
157156

158157
@PublishedApi
159-
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
160-
@LowPriorityInOverloadResolution
161-
internal fun LocalDate.until(other: LocalDate, unit: DateTimeUnit.DateBased): Int =
158+
@JvmName("until")
159+
internal fun LocalDate.untilJvm(other: LocalDate, unit: DateTimeUnit.DateBased): Int =
162160
until(other, unit).clampToInt()
163161

164162
public actual fun LocalDate.daysUntil(other: LocalDate): Int =

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ versionSuffix=SNAPSHOT
77

88
tzdbVersion=2025a
99

10-
defaultKotlinVersion=1.9.21
10+
defaultKotlinVersion=2.1.0
1111
dokkaVersion=1.9.20
1212
serializationVersion=1.6.2
1313
benchmarksVersion=0.7.2

0 commit comments

Comments
 (0)