Skip to content

Commit 76b12f9

Browse files
authored
Restructure README (multiplatform) (#2495)
Fixes #2447
1 parent 2ec1290 commit 76b12f9

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

README.md

+31-31
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,6 @@ plugins {
145145

146146
Make sure that you have either `jcenter()` or `mavenCentral()` in the list of repositories.
147147

148-
### Multiplatform
149-
150-
Core modules of `kotlinx.coroutines` are also available for
151-
[Kotlin/JS](#js) and [Kotlin/Native](#native).
152-
In common code that should get compiled for different platforms, you can add dependency to `kotlinx-coroutines-core` right to the `commonMain` source set:
153-
```groovy
154-
commonMain {
155-
dependencies {
156-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2")
157-
}
158-
}
159-
```
160-
161148
### Android
162149

163150
Add [`kotlinx-coroutines-android`](ui/kotlinx-coroutines-android)
@@ -169,13 +156,13 @@ implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2'
169156

170157
This gives you access to Android [Dispatchers.Main]
171158
coroutine dispatcher and also makes sure that in case of crashed coroutine with unhandled exception this
172-
exception is logged before crashing Android application, similarly to the way uncaught exceptions in
173-
threads are handled by Android runtime.
159+
exception is logged before crashing Android application, similarly to the way uncaught exceptions in
160+
threads are handled by Android runtime.
174161

175162
#### R8 and ProGuard
176163

177164
R8 and ProGuard rules are bundled into the [`kotlinx-coroutines-android`](ui/kotlinx-coroutines-android) module.
178-
For more details see ["Optimization" section for Android](ui/kotlinx-coroutines-android/README.md#optimization).
165+
For more details see ["Optimization" section for Android](ui/kotlinx-coroutines-android/README.md#optimization).
179166

180167
#### Avoiding including the debug infrastructure in the resulting APK
181168

@@ -188,27 +175,40 @@ packagingOptions {
188175
}
189176
```
190177

191-
### JS
178+
### Multiplatform
179+
180+
Core modules of `kotlinx.coroutines` are also available for
181+
[Kotlin/JS](https://kotlinlang.org/docs/reference/js-overview.html) and [Kotlin/Native](https://kotlinlang.org/docs/reference/native-overview.html).
182+
183+
In common code that should get compiled for different platforms, you can add dependency to `kotlinx-coroutines-core` right to the `commonMain` source set:
184+
```groovy
185+
commonMain {
186+
dependencies {
187+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2")
188+
}
189+
}
190+
```
191+
192+
No more additional dependencies is needed, platform-specific artifacts will be resolved automatically via Gradle metadata available since Gradle 5.3.
193+
194+
Platform-specific dependencies are recommended to be used only for non-multiplatform projects that are compiled only for target platform.
195+
196+
#### JS
192197

193-
[Kotlin/JS](https://kotlinlang.org/docs/js-overview.html) version of `kotlinx.coroutines` is published as
198+
Kotlin/JS version of `kotlinx.coroutines` is published as
194199
[`kotlinx-coroutines-core-js`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.4.2/jar)
195-
(follow the link to get the dependency declaration snippet).
196-
197-
You can also use [`kotlinx-coroutines-core`](https://www.npmjs.com/package/kotlinx-coroutines-core) package via NPM.
200+
(follow the link to get the dependency declaration snippet) and as [`kotlinx-coroutines-core`](https://www.npmjs.com/package/kotlinx-coroutines-core) NPM package.
198201

199-
### Native
202+
#### Native
200203

201-
[Kotlin/Native](https://kotlinlang.org/docs/native-overview.html) version of `kotlinx.coroutines` is published as
202-
[`kotlinx-coroutines-core-native`](https://search.maven.org/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-native/1.4.2/jar)
203-
(follow the link to get the dependency declaration snippet).
204+
Kotlin/Native version of `kotlinx.coroutines` is published as
205+
[`kotlinx-coroutines-core-$platform`](https://mvnrepository.com/search?q=kotlinx-coroutines-core-) where `$platform` is
206+
the target Kotlin/Native platform. [List of currently supported targets](https://github.com/Kotlin/kotlinx.coroutines/blob/master/gradle/compile-native-multiplatform.gradle#L16).
204207

205-
Only single-threaded code (JS-style) on Kotlin/Native is currently supported.
206-
Kotlin/Native supports only Gradle version 4.10 and you need to enable Gradle metadata in your
207-
`settings.gradle` file:
208208

209-
```groovy
210-
enableFeaturePreview('GRADLE_METADATA')
211-
```
209+
Only single-threaded code (JS-style) on Kotlin/Native is supported in stable versions.
210+
Additionally, special `-native-mt` version is released on a regular basis, for the state of multi-threaded coroutines support
211+
please follow the [corresponding issue](https://github.com/Kotlin/kotlinx.coroutines/issues/462) for the additional details.
212212

213213
Since Kotlin/Native does not generally provide binary compatibility between versions,
214214
you should use the same version of Kotlin/Native compiler as was used to build `kotlinx.coroutines`.

0 commit comments

Comments
 (0)