diff --git a/README.md b/README.md index 03051eadde..d9019dc335 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,12 @@ [![Kotlin Stable](https://kotl.in/badges/stable.svg)](https://kotlinlang.org/docs/components-stability.html) [![JetBrains official project](https://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub) [![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0) -[![Download](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.4.3)](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.4.3/pom) -[![Kotlin](https://img.shields.io/badge/kotlin-1.4.30-blue.svg?logo=kotlin)](http://kotlinlang.org) +[![Download](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.6.4)](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.6.4/pom) +[![Kotlin](https://img.shields.io/badge/kotlin-1.6.21-blue.svg?logo=kotlin)](http://kotlinlang.org) [![Slack channel](https://img.shields.io/badge/chat-slack-green.svg?logo=slack)](https://kotlinlang.slack.com/messages/coroutines/) Library support for Kotlin coroutines with [multiplatform](#multiplatform) support. -This is a companion version for Kotlin `1.4.30` release. +This is a companion version for the Kotlin `1.6.21` release. ```kotlin suspend fun main() = coroutineScope { @@ -84,7 +84,7 @@ Add dependencies (you can also add other modules that you need): org.jetbrains.kotlinx kotlinx-coroutines-core - 1.4.3 + 1.6.4 ``` @@ -92,7 +92,7 @@ And make sure that you use the latest Kotlin version: ```xml - 1.4.30 + 1.6.21 ``` @@ -100,61 +100,45 @@ And make sure that you use the latest Kotlin version: Add dependencies (you can also add other modules that you need): -```groovy +```kotlin dependencies { - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3' + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") } ``` And make sure that you use the latest Kotlin version: -```groovy -buildscript { - ext.kotlin_version = '1.4.30' +```kotlin +plugins { + // For build.gradle.kts (Kotlin DSL) + kotlin("jvm") version "1.6.21" + + // For build.gradle (Groovy DSL) + id "org.jetbrains.kotlin.jvm" version "1.6.21" } ``` Make sure that you have `mavenCentral()` in the list of repositories: -``` -repository { +```kotlin +repositories { mavenCentral() } ``` -### Gradle Kotlin DSL - -Add dependencies (you can also add other modules that you need): - -```groovy -dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3") -} -``` - -And make sure that you use the latest Kotlin version: - -```groovy -plugins { - kotlin("jvm") version "1.4.30" -} -``` - -Make sure that you have `mavenCentral()` in the list of repositories. - ### Android Add [`kotlinx-coroutines-android`](ui/kotlinx-coroutines-android) -module as dependency when using `kotlinx.coroutines` on Android: +module as a dependency when using `kotlinx.coroutines` on Android: -```groovy -implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3' +```kotlin +implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4") ``` -This gives you access to Android [Dispatchers.Main] -coroutine dispatcher and also makes sure that in case of crashed coroutine with unhandled exception this -exception is logged before crashing Android application, similarly to the way uncaught exceptions in -threads are handled by Android runtime. +This gives you access to the Android [Dispatchers.Main] +coroutine dispatcher and also makes sure that in case of a crashed coroutine with an unhandled exception that +this exception is logged before crashing the Android application, similarly to the way uncaught exceptions in +threads are handled by the Android runtime. #### R8 and ProGuard @@ -165,8 +149,9 @@ For more details see ["Optimization" section for Android](ui/kotlinx-coroutines- The `kotlinx-coroutines-core` artifact contains a resource file that is not required for the coroutines to operate normally and is only used by the debugger. To exclude it at no loss of functionality, add the following snippet to the -`android` block in your gradle file for the application subproject: -```groovy +`android` block in your Gradle file for the application subproject: + +```kotlin packagingOptions { resources.excludes += "DebugProbesKt.bin" } @@ -177,23 +162,24 @@ packagingOptions { Core modules of `kotlinx.coroutines` are also available for [Kotlin/JS](https://kotlinlang.org/docs/reference/js-overview.html) and [Kotlin/Native](https://kotlinlang.org/docs/reference/native-overview.html). -In common code that should get compiled for different platforms, you can add dependency to `kotlinx-coroutines-core` right to the `commonMain` source set: -```groovy +In common code that should get compiled for different platforms, you can add a dependency to `kotlinx-coroutines-core` right to the `commonMain` source set: + +```kotlin commonMain { dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") } } ``` -No more additional dependencies is needed, platform-specific artifacts will be resolved automatically via Gradle metadata available since Gradle 5.3. +No more additional dependencies are needed, platform-specific artifacts will be resolved automatically via Gradle metadata available since Gradle 5.3. Platform-specific dependencies are recommended to be used only for non-multiplatform projects that are compiled only for target platform. #### JS Kotlin/JS version of `kotlinx.coroutines` is published as -[`kotlinx-coroutines-core-js`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.4.3/jar) +[`kotlinx-coroutines-core-js`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.6.4/jar) (follow the link to get the dependency declaration snippet) and as [`kotlinx-coroutines-core`](https://www.npmjs.com/package/kotlinx-coroutines-core) NPM package. #### Native @@ -202,14 +188,6 @@ Kotlin/Native version of `kotlinx.coroutines` is published as [`kotlinx-coroutines-core-$platform`](https://mvnrepository.com/search?q=kotlinx-coroutines-core-) where `$platform` is the target Kotlin/Native platform. [List of currently supported targets](https://github.com/Kotlin/kotlinx.coroutines/blob/master/gradle/compile-native-multiplatform.gradle#L16). - -Only single-threaded code (JS-style) on Kotlin/Native is supported in stable versions. -Additionally, special `-native-mt` version is released on a regular basis, for the state of multi-threaded coroutines support -please follow the [corresponding issue](https://github.com/Kotlin/kotlinx.coroutines/issues/462) for the additional details. - -Since Kotlin/Native does not generally provide binary compatibility between versions, -you should use the same version of Kotlin/Native compiler as was used to build `kotlinx.coroutines`. - ## Building and Contributing See [Contributing Guidelines](CONTRIBUTING.md).