Skip to content

Commit e5aa8ec

Browse files
authored
feat: Kotlin 2.1.20-RC2 release (#4732)
1 parent 96990c6 commit e5aa8ec

File tree

4 files changed

+143
-19
lines changed

4 files changed

+143
-19
lines changed

docs/kr.tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</toc-element>
2525
<toc-element toc-title="What's new in Kotlin">
2626
<toc-element toc-title="Kotlin 2.1.0" accepts-web-file-names="whatsnew.html" topic="whatsnew21.md"/>
27-
<toc-element toc-title="Kotlin 2.1.20-RC" topic="whatsnew-eap.md"/>
27+
<toc-element toc-title="Kotlin 2.1.20-RC2" topic="whatsnew-eap.md"/>
2828
<toc-element toc-title="Earlier versions">
2929
<toc-element toc-title="Kotlin 2.0.20" topic="whatsnew2020.md"/>
3030
<toc-element toc-title="Kotlin 2.0.0" topic="whatsnew20.md"/>

docs/topics/eap.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ In this channel, you can also get notifications about new EAP builds.
4343
<th>Build highlights</th>
4444
</tr>
4545
<tr>
46-
<td><strong>2.1.20-RC</strong>
47-
<p>Released: <strong>February 19, 2025</strong></p>
48-
<p><a href="https://github.com/JetBrains/kotlin/releases/tag/v2.1.20-RC" target="_blank">Release on GitHub</a></p>
46+
<td><strong>2.1.20-RC2</strong>
47+
<p>Released: <strong>March 6, 2025</strong></p>
48+
<p><a href="https://github.com/JetBrains/kotlin/releases/tag/v2.1.20-RC2" target="_blank">Release on GitHub</a></p>
4949
</td>
5050
<td>
5151
<p>A tooling release with K2 kapt enabled by default.</p>
52-
<p>For more details, please refer to the <a href="https://github.com/JetBrains/kotlin/releases/tag/v2.1.20-RC">changelog</a> or <a href="whatsnew-eap.md">What's new in Kotlin 2.1.20-RC</a>.</p>
52+
<p>For more details, please refer to the <a href="https://github.com/JetBrains/kotlin/releases/tag/v2.1.20-RC2">changelog</a> or <a href="whatsnew-eap.md">What's new in Kotlin 2.1.20-RC2</a>.</p>
5353
</td>
5454
</tr>
5555
</table>

docs/topics/whatsnew-eap.md

Lines changed: 136 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ Here are some details of this EAP release:
1515
* [](#kotlin-k2-compiler-new-default-kapt-plugin)
1616
* [](#kotlin-multiplatform-new-dsl-to-replace-gradle-s-application-plugin)
1717
* [](#kotlin-native-new-inlining-optimization)
18-
* [Kotlin/Wasm: migration to Provider API](#kotlin-wasm-migration-to-provider-api-for-kotlin-wasm-and-kotlin-js-properties)
19-
* [Gradle: support for custom publication variants](#support-for-adding-custom-gradle-publication-variants)
20-
* [](#common-atomic-types)
21-
* [](#changes-in-uuid-parsing-and-formatting-functions)
18+
* [Kotlin/Wasm: default custom formatters and migration to Provider API](#kotlin-wasm)
19+
* [Gradle: support for Gradle 8.11, compatibility with Isolated Projects, and custom publication variants](#support-for-adding-custom-gradle-publication-variants)
20+
* [Standard library: common atomic types, improved UUID support, and new time tracking functionality](#standard-library)
2221
* [](#compose-compiler-source-information-included-by-default)
2322

2423
## IDE support
@@ -30,7 +29,6 @@ All you need to do is to [change the Kotlin version](configure-build-for-eap.md)
3029
See [Update to a new release](releases.md#update-to-a-new-kotlin-version) for details.
3130

3231
## Kotlin K2 compiler: new default kapt plugin
33-
3432
<primary-label ref="beta"/>
3533

3634
Starting with Kotlin %kotlinEapVersion%, the K2 implementation of the kapt compiler plugin is enabled by default
@@ -52,7 +50,6 @@ kapt.use.k2=false
5250
Please report any issues to our [issue tracker](https://youtrack.jetbrains.com/issue/KT-71439/K2-kapt-feedback).
5351

5452
## Kotlin Multiplatform: new DSL to replace Gradle's Application plugin
55-
5653
<primary-label ref="experimental-opt-in"/>
5754

5855
Starting with Gradle 8.7, the [Application](https://docs.gradle.org/current/userguide/application_plugin.html) plugin is
@@ -126,7 +123,43 @@ gives an overall performance improvement of 9.5%. Of course, you can try out oth
126123
If you experience increased binary size or compilation time, please report such issues
127124
in [YouTrack](https://kotl.in/issue).
128125

129-
## Kotlin/Wasm: migration to Provider API for Kotlin/Wasm and Kotlin/JS properties
126+
## Kotlin/Wasm
127+
128+
### Custom formatters enabled by default
129+
130+
Before, you had to [manually configure](whatsnew21.md#improved-debugging-experience-for-kotlin-wasm) custom formatters
131+
to improve debugging in web browsers when working with Kotlin/Wasm code.
132+
133+
In this release, custom formatters are enabled by default in development builds, so no additional Gradle configuration
134+
is needed.
135+
136+
To use this feature, you only need to ensure that custom formatters are enabled in your browser's developer tools:
137+
138+
* In Chrome DevTools, it's available via **Settings | Preferences | Console**:
139+
140+
![Enable custom formatters in Chrome](wasm-custom-formatters-chrome.png){width=400}
141+
142+
* In Firefox DevTools, it's available via **Settings | Advanced settings**:
143+
144+
![Enable custom formatters in Firefox](wasm-custom-formatters-firefox.png){width=400}
145+
146+
This change primarily affects development builds. If you have specific requirements for production builds,
147+
you need to adjust your Gradle configuration accordingly. Add the following compiler option to the `wasmJs {}` block:
148+
149+
```kotlin
150+
// build.gradle.kts
151+
kotlin {
152+
wasmJs {
153+
// ...
154+
155+
compilerOptions {
156+
freeCompilerArgs.add("-Xwasm-debugger-custom-formatters")
157+
}
158+
}
159+
}
160+
```
161+
162+
### Migration to Provider API for Kotlin/Wasm and Kotlin/JS properties
130163

131164
Previously, properties in Kotlin/Wasm and Kotlin/JS extensions were mutable (`var`) and assigned directly in build
132165
scripts:
@@ -172,6 +205,36 @@ must update property assignments to use the `.set()` function.
172205
### Support for version 8.11
173206
Kotlin %kotlinEapVersion% is now compatible with the latest stable Gradle version, 8.11, and supports its features.
174207

208+
### Kotlin Gradle plugin compatible with Gradle's Isolated Projects
209+
<primary-label ref="experimental-opt-in"/>
210+
211+
> This feature is currently in a pre-Alpha state in Gradle.
212+
> Use it only with Gradle version 8.10 or higher and solely for evaluation purposes.
213+
>
214+
{style="warning"}
215+
216+
Since Kotlin 2.1.0, you've been able to [preview Gradle's Isolated Projects feature](whatsnew21.md#preview-gradle-s-isolated-projects-in-kotlin-multiplatform)
217+
in your projects.
218+
219+
Previously, you had to configure the Kotlin Gradle plugin to make your project compatible with the Isolated Projects
220+
feature before you could try it out. In Kotlin %kotlinEapVersion%, this additional step is no longer necessary.
221+
222+
Now, to enable the Isolated Projects feature, you only need to [set the system property](https://docs.gradle.org/current/userguide/isolated_projects.html#how_do_i_use_it).
223+
224+
Gradle’s Isolated Projects feature is supported in Kotlin Gradle plugins for both multiplatform projects and projects
225+
that contain only the JVM or Android target.
226+
227+
Specifically for multiplatform projects, if you notice problems with your Gradle build after upgrading, you can opt out
228+
of the new Kotlin Gradle plugin behavior by setting:
229+
230+
```none
231+
kotlin.kmp.isolated-projects.support=disable
232+
```
233+
234+
However, if you use this Gradle property in your multiplatform project, you can't use the Isolated Projects feature.
235+
236+
We would appreciate your feedback on this feature in [YouTrack](https://youtrack.jetbrains.com/issue/KT-57279/Support-Gradle-Project-Isolation-Feature-for-Kotlin-Multiplatform).
237+
175238
### Support for adding custom Gradle publication variants
176239
<primary-label ref="experimental-opt-in"/>
177240

@@ -182,9 +245,8 @@ This feature is available for multiplatform projects and projects targeting the
182245
>
183246
{style="note"}
184247

185-
This feature is [Experimental](components-stability.md#stability-levels-explained). To opt in,
186-
use the `@OptIn(ExperimentalKotlinGradlePluginApi::class)` annotation or the compiler option
187-
`-opt-in=kotlin.ExperimentalKotlinGradlePluginApi`.
248+
This feature is [Experimental](components-stability.md#stability-levels-explained).
249+
To opt in, use the `@OptIn(ExperimentalKotlinGradlePluginApi::class)` annotation.
188250

189251
To add a custom Gradle publication variant, invoke the `adhocSoftwareComponent()` function, which returns an instance
190252
of [`AdhocComponentWithVariants`](https://docs.gradle.org/current/javadoc/org/gradle/api/component/AdhocComponentWithVariants.html)
@@ -291,7 +353,7 @@ fun main() {
291353
```
292354
{validate="false" kotlin-runnable="true" kotlin-min-compiler-version="2.1.20"}
293355

294-
### Changes in UUID parsing and formatting functions
356+
### Changes in UUID parsing, formatting, and comparability
295357
<primary-label ref="experimental-opt-in"/>
296358

297359
The JetBrains team continues to improve the support for UUIDs [introduced to the standard library in 2.0.20](whatsnew2020.md#support-for-uuids-in-the-common-kotlin-standard-library).
@@ -309,8 +371,13 @@ and [`toHexString()`](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.uuid/
309371
introduced earlier for the hexadecimal format. Explicit naming for parsing and formatting functionality should improve
310372
code clarity and your overall experience with UUIDs.
311373

374+
UUIDs in Kotlin are now `Comparable`. Starting with Kotlin %kotlinEapVersion%, you can directly compare and sort values
375+
of the `Uuid` type. This enables the use of the `<` and `>` operators, standard library extensions available exclusively
376+
for `Comparable` types or their collections (such as `sorted()`), and allows passing UUIDs to any functions or APIs that
377+
require the `Comparable` interface.
378+
312379
Remember that the UUID support in the standard library is still [Experimental](components-stability.md#stability-levels-explained).
313-
To opt in, use the `@ExperimentalUuidApi` annotation or the compiler option `-opt-in=kotlin.uuid.ExperimentalUuidApi`:
380+
To opt in, use the `@OptIn(ExperimentalUuidApi::class)` annotation or the compiler option `-opt-in=kotlin.uuid.ExperimentalUuidApi`:
314381

315382
```kotlin
316383
import kotlin.uuid.ExperimentalUuidApi
@@ -327,11 +394,68 @@ fun main() {
327394

328395
// Outputs the UUID in the hex-and-dash format
329396
println(hexDashFormat)
397+
398+
// Outputs UUIDs in ascending order
399+
println(
400+
listOf(
401+
uuid,
402+
Uuid.parse("780e8400e29b41d4a716446655440005"),
403+
Uuid.parse("5ab88400e29b41d4a716446655440076")
404+
).sorted()
405+
)
330406
}
331407
//sampleEnd
332408
```
333409
{validate="false" kotlin-runnable="true" kotlin-min-compiler-version="2.1.20"}
334410

411+
### New time tracking functionality
412+
<primary-label ref="experimental-opt-in"/>
413+
414+
Starting with Kotlin %kotlinEapVersion%, the standard library provides the ability to represent a moment in time.
415+
This functionality was previously only available in [`kotlinx-datetime`](https://kotlinlang.org/api/kotlinx-datetime/),
416+
an official Kotlin library.
417+
418+
The [kotlinx.datetime.Clock](https://kotlinlang.org/api/kotlinx-datetime/kotlinx-datetime/kotlinx.datetime/-clock/)
419+
interface is introduced to the standard library as `kotlin.time.Clock` and the [`kotlinx.datetime.Instant`](https://kotlinlang.org/api/kotlinx-datetime/kotlinx-datetime/kotlinx.datetime/-instant/)
420+
class as `kotlin.time.Instant`. These concepts naturally align with the `time` package in the standard library because
421+
they’re only concerned with moments in time compared to a more complex calendar and timezone functionality that remains
422+
in `kotlinx-datetime`.
423+
424+
`Instant` and `Clock` are useful when you need precise time tracking without considering time zones or dates.
425+
For example, you can use them to log events with timestamps, measure durations between two points in time,
426+
and obtain the current moment for system processes.
427+
428+
To provide interoperability with other languages, additional converter functions are available:
429+
430+
* `.toKotlinInstant()` converts a time value to a `kotlin.time.Instant` instance.
431+
* `.toJavaInstant()` converts the `kotlin.time.Instant` value to a `java.time.Instant` value.
432+
* `Instant.toJSDate()` converts the `kotlin.time.Instant` value to an instance of the JS `Date` class. This conversion
433+
is not precise, JS uses millisecond precision to represent dates, while Kotlin allows for nanosecond resolution.
434+
435+
The new time features of the standard library are still [Experimental](components-stability.md#stability-levels-explained).
436+
To opt in, use the `@OptIn(ExperimentalTime::class)` annotation:
437+
438+
```kotlin
439+
import kotlin.time.*
440+
441+
@OptIn(ExperimentalTime::class)
442+
fun main() {
443+
444+
// Get the current moment in time
445+
val currentInstant = Clock.System.now()
446+
println("Current time: $currentInstant")
447+
448+
// Find the difference between two moments in time
449+
val pastInstant = Instant.parse("2023-01-01T00:00:00Z")
450+
val duration = currentInstant - pastInstant
451+
452+
println("Time elapsed since 2023-01-01: $duration")
453+
}
454+
```
455+
{validate="false" kotlin-runnable="true" kotlin-min-compiler-version="2.1.20"}
456+
457+
For more information on the implementation, see this [KEEP proposal](https://github.com/Kotlin/KEEP/pull/387/files).
458+
335459
## Compose compiler: source information included by default
336460

337461
The Compose compiler Gradle plugin enables [including source information](https://kotlinlang.org/api/kotlin-gradle-plugin/compose-compiler-gradle-plugin/org.jetbrains.kotlin.compose.compiler.gradle/-compose-compiler-gradle-plugin-extension/include-source-information.html)

docs/v.list

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<var name="apiVersion" value="2.1" type="string"/>
1414

1515
<!-- Kotlin EAP -->
16-
<var name="kotlinEapVersion" value="2.1.20-RC" type="string"/>
17-
<var name="kotlinEapReleaseDate" value="February 19, 2025" type="string"/>
16+
<var name="kotlinEapVersion" value="2.1.20-RC2" type="string"/>
17+
<var name="kotlinEapReleaseDate" value="March 6, 2025" type="string"/>
1818

1919
<!-- Libraries and Frameworks -->
2020
<var name="coroutinesVersion" value="1.10.1" type="string"/>

0 commit comments

Comments
 (0)