Skip to content

Commit 705ba56

Browse files
committed
Documentation for Kotlin/Native support
1 parent a608a33 commit 705ba56

File tree

8 files changed

+201
-17
lines changed

8 files changed

+201
-17
lines changed

README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)
55
[![Download](https://api.bintray.com/packages/kotlin/kotlinx/kotlinx.coroutines/images/download.svg?version=0.23.4) ](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines/0.23.4)
66

7-
Library support for Kotlin coroutines in
8-
[Kotlin/JVM](core/README.md) and
9-
[Kotlin/JS](js/README.md).
7+
Library support for Kotlin coroutines with [multiplatform](#multiplatform) support.
108
This is a companion version for Kotlin 1.2.51 release.
119

1210
```kotlin
@@ -22,12 +20,13 @@ launch {
2220
* `launch` and `async` coroutine builders;
2321
* `Job` and `Deferred` light-weight future with cancellation support;
2422
* `delay` and `yield` top-level suspending functions.
25-
* [js](js/README.md) — Kotlin/JS implementation of common coroutines with `Promise` support.
2623
* [core](core/README.md) — Kotlin/JVM implementation of common coroutines with additional features:
2724
* `CommonPool` coroutine context (default on JVM);
2825
* `Channel` and `Mutex` communication and synchronization primitives;
2926
* `produce` and `actor` coroutine builders;
3027
* `select` expression support and more.
28+
* [js](js/README.md) — Kotlin/JS implementation of common coroutines with `Promise` support.
29+
* [native](native/README.md) — Kotlin/Native implementation of common coroutines with `runBlocking` single-threaded event loop.
3130
* [reactive](reactive/README.md) — modules that provide builders and iteration support for various reactive streams libraries:
3231
* Reactive Streams, RxJava 1.x and 2.x and Project Reactor.
3332
* [ui](ui/README.md) — modules that provide coroutine dispatchers for various single-threaded UI libraries:
@@ -100,10 +99,13 @@ repository {
10099
}
101100
```
102101

103-
### Kotlin/JS
102+
### Multiplatform
104103

105-
Use `org.jetbrains.kotlinx:kotlinx-coroutines-core-js:<version>` artifact in your Gradle/Maven dependencies
106-
or install [`kotlinx-coroutines-core`](https://www.npmjs.com/package/kotlinx-coroutines-core) package via NPM.
104+
Core modules of `kotlinx.coroutines` are also available for
105+
[Kotlin/JS](js/README.md) and [Kotlin/Native](native/README.md). If you write
106+
a common code that should get compiled or different platforms, add
107+
[`org.jetbrains.kotlinx:kotlinx-coroutines-core-common:<version>`](common/kotlinx-coroutines-core-common/README.md)
108+
to your common code dependencies.
107109

108110
### Android
109111

common/kotlinx-coroutines-core-common/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Common primitives to work with coroutines in
66
Documentation is provided in platform-specific modules:
77
* [kotlinx-coroutines-core](../../core/kotlinx-coroutines-core/README.md) for Kotlin/JVM.
88
* [kotlinx-coroutines-core-js](../../js/kotlinx-coroutines-core-js/README.md) for Kotlin/JS.
9+
* [kotlinx-coroutines-core-native](../../native/kotlinx-coroutines-core-native/README.md) for Kotlin/Native.

gradle/dokka.gradle

+6-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ if (platform == "jvm") {
4242
makeLinkMapping(it, rootProject.file("js/$project.name-js"))
4343
makeLinkMapping(it, rootProject.file("common/$project.name-common"))
4444
// source roots
45-
impliedPlatforms = ['JVM', 'JS']
45+
impliedPlatforms = ['JVM', 'JS', 'Native']
4646
sourceRoot {
4747
path = rootProject.file("core/$project.name/src")
4848
platforms = ['JVM']
@@ -51,10 +51,14 @@ if (platform == "jvm") {
5151
path = rootProject.file("js/$project.name-js/src")
5252
platforms = ['JS']
5353
}
54+
sourceRoot {
55+
path = rootProject.file("native/$project.name-native/src")
56+
platforms = ['Native']
57+
}
5458
sourceRoot {
5559
path = rootProject.file("common/$project.name-common/src")
5660
}
57-
// depends on JS & Common, too
61+
// depends on other platforms, too
5862
afterEvaluate {
5963
dependsOn(tasks.getByPath(":$project.name:classes"))
6064
dependsOn(tasks.getByPath(":$project.name-js:classes"))

js/README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# Coroutines core for Kotlin/JS
22

33
This directory contains modules that provide core coroutines support on Kotlin/JS.
4-
Module name below corresponds to the artifact name in Maven/Gradle.
54

6-
## Modules
5+
## Using in your projects
76

8-
* [kotlinx-coroutines-core-js](kotlinx-coroutines-core-js/README.md) -- core coroutine builders and primitives.
7+
Use [`org.jetbrains.kotlinx:kotlinx-coroutines-core-js:<version>`](kotlinx-coroutines-core-js/README.md)
8+
module in your Gradle/Maven dependencies
9+
or install [`kotlinx-coroutines-core`](https://www.npmjs.com/package/kotlinx-coroutines-core) package via NPM.
10+
11+
Since Kotlin/JS does not generally provide binary compatibility between versions,
12+
you should use the same version of Kotlin compiler as was used to build `kotlinx.coroutines`.
13+
See [gradle.properties](../gradle.properties).
914

1015
## Examples
1116

js/kotlinx-coroutines-core-js/README.md

-4
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ helper function. [NonCancellable] job object is provided to suppress cancellatio
5959
| [Mutex][kotlinx.coroutines.experimental.sync.Mutex] | [lock][kotlinx.coroutines.experimental.sync.Mutex.lock] | [onLock][kotlinx.coroutines.experimental.sync.Mutex.onLock] | [tryLock][kotlinx.coroutines.experimental.sync.Mutex.tryLock]
6060
| none | [delay] | [onTimeout][kotlinx.coroutines.experimental.selects.SelectBuilder.onTimeout] | none
6161

62-
# Package kotlinx.coroutines.experimental
63-
64-
General-purpose coroutine builders, contexts, and helper functions.
65-
6662
<!--- MODULE kotlinx-coroutines-core -->
6763
<!--- INDEX kotlinx.coroutines.experimental -->
6864
[launch]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.experimental/launch.html

knit/resources/knit.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
site.root=https://kotlin.github.io/kotlinx.coroutines
66

7-
module.roots=common js core integration reactive ui
7+
module.roots=common js core integration native reactive ui
88
module.marker=build.gradle
99
module.docs=build/dokka

native/README.md

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Coroutines core for Kotlin/Native
2+
3+
This directory contains modules that provide core coroutines support on Kotlin/Native.
4+
5+
## Using in your projects
6+
7+
Use [`org.jetbrains.kotlinx:kotlinx-coroutines-core-native:<version>`](kotlinx-coroutines-core-native/README.md)
8+
module in your Gradle/Maven dependencies.
9+
Only single-threaded code (JS-style) is currently supported.
10+
11+
Kotlin/Native supports only Gradle version 4.7 or later
12+
and you should use `kotlin-platform-native` plugin.
13+
14+
First of all, you'll need to enable Gradle metadata in your
15+
`settings.gradle` file:
16+
17+
```groovy
18+
enableFeaturePreview('GRADLE_METADATA')
19+
```
20+
21+
Then, you'll need to apply the corresponding plugin and add appropriate dependencies in your
22+
`build.gradle` file:
23+
24+
```groovy
25+
buildscript {
26+
repositories {
27+
jcenter()
28+
maven { url 'https://plugins.gradle.org/m2/' }
29+
maven { url 'https://dl.bintray.com/jetbrains/kotlin-native-dependencies' }
30+
}
31+
32+
dependencies {
33+
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version"
34+
}
35+
36+
}
37+
38+
apply plugin: 'kotlin-platform-native'
39+
40+
repositories {
41+
jcenter()
42+
}
43+
44+
dependencies {
45+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core-native:0.23.4'
46+
}
47+
48+
sourceSets {
49+
main {
50+
component {
51+
target "ios_arm64", "ios_arm32", "ios_x64", "macos_x64", "linux_x64", "mingw_x64"
52+
outputKinds = [EXECUTABLE]
53+
}
54+
}
55+
}
56+
```
57+
58+
Since Kotlin/Native does not generally provide binary compatibility between versions,
59+
you should use the same version of Kotlin/Native compiler as was used to build `kotlinx.coroutines`.
60+
Add an appropriate `kotlin_native_version` to your `gradle.properties` file.
61+
See [gradle.properties](../gradle.properties).
62+

0 commit comments

Comments
 (0)