Skip to content

Commit ca83391

Browse files
committed
Merge branch 'develop'
2 parents d2d42ea + db667eb commit ca83391

File tree

169 files changed

+8476
-1702
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+8476
-1702
lines changed

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
/.idea
1+
.idea
22
*.iml
33
.gradle
4+
.gradletasknamecache
45
build
56
out
6-
target
7+
target
8+
node_modules
9+
package-lock.json

CHANGES.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Change log for kotlinx.coroutines
22

3+
## Version 0.21
4+
5+
* Migrated to Kotlin 1.2.10.
6+
* Coroutines library for [Kotlin/JS](js/README.md) and [multiplatform projects](https://kotlinlang.org/docs/reference/multiplatform.html) (see #33):
7+
* `launch` and `async` coroutine builders.
8+
* `Job` and `Deferred` light-weight future with cancellation support.
9+
* `delay` and `yield` top-level suspending functions.
10+
* `await` extension for JS `Promise` and `asPromise`/`asDeferred` conversions.
11+
* `promise` coroutine builder.
12+
* `Job()` and `CompletableDeferred()` factories.
13+
* Full support for parent-child coroutine hierarchies.
14+
* `Window.awaitAnimationFrame` extension function.
15+
* [Sample frontend Kotlin/JS application](js/example-frontend-js/README.md) with coroutine-driven animations.
16+
* `run` is deprecated and renamed to `withContext` (see #134).
17+
* `runBlocking` and `EventLoop` implementations optimized (see #190).
18+
319
## Version 0.20
420

521
* Migrated to Kotlin 1.2.0.

README.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,31 @@
22

33
[![official JetBrains project](http://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
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)
5-
[![Download](https://api.bintray.com/packages/kotlin/kotlinx/kotlinx.coroutines/images/download.svg?version=0.20) ](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines/0.20)
5+
[![Download](https://api.bintray.com/packages/kotlin/kotlinx/kotlinx.coroutines/images/download.svg?version=0.21) ](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines/0.21)
66

7-
Library support for Kotlin coroutines.
8-
This is a companion version for Kotlin 1.2.0 release.
7+
Library support for Kotlin coroutines in
8+
[Kotlin/JVM](core/README.md) and
9+
[Kotlin/JS](js/README.md).
10+
This is a companion version for Kotlin 1.2.10 release.
11+
12+
```kotlin
13+
launch {
14+
delay(1000)
15+
println("Hello from Kotlin Coroutines!")
16+
}
17+
```
918

1019
## Modules
1120

12-
* [core](core/README.md) -- core primitives to work with coroutines:
13-
* `launch`, `async`, `produce`, `actor`, etc coroutine builders;
21+
* [common](common/README.md) - common coroutines across all backends:
22+
* `launch` and `async` coroutine builders;
1423
* `Job` and `Deferred` light-weight future with cancellation support;
15-
* `CommonPool` and other coroutine contexts;
24+
* `delay` and `yield` top-level suspending functions.
25+
* [js](js/README.md) - Kotlin/JS implementation of common coroutines with `Promise` support.
26+
* [core](core/README.md) -- Kotlin/JVM implementation of common coroutines with additional features:
27+
* `CommonPool` coroutine context (default on JVM);
1628
* `Channel` and `Mutex` communication and synchronization primitives;
17-
* `delay`, `yield`, etc top-level suspending functions;
29+
* `produce` and `actor` coroutine builders;
1830
* `select` expression support and more.
1931
* [reactive](reactive/README.md) -- modules that provide builders and iteration support for various reactive streams libraries:
2032
* Reactive Streams, RxJava 1.x and 2.x and Project Reactor.
@@ -52,15 +64,15 @@ Add dependencies (you can also add other modules that you need):
5264
<dependency>
5365
<groupId>org.jetbrains.kotlinx</groupId>
5466
<artifactId>kotlinx-coroutines-core</artifactId>
55-
<version>0.20</version>
67+
<version>0.21</version>
5668
</dependency>
5769
```
5870

5971
And make sure that you use the latest Kotlin version:
6072

6173
```xml
6274
<properties>
63-
<kotlin.version>1.2.0</kotlin.version>
75+
<kotlin.version>1.2.10</kotlin.version>
6476
</properties>
6577
```
6678

@@ -69,17 +81,21 @@ And make sure that you use the latest Kotlin version:
6981
Add dependencies (you can also add other modules that you need):
7082

7183
```groovy
72-
compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.20'
84+
compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.21'
7385
```
7486

7587
And make sure that you use the latest Kotlin version:
7688

7789
```groovy
7890
buildscript {
79-
ext.kotlin_version = '1.2.0'
91+
ext.kotlin_version = '1.2.10'
8092
}
8193
```
8294

95+
### Kotlin/JS
96+
97+
Use `kotlinx-coroutines-core-js` artifact in your dependencies.
98+
8399
### ProGuard
84100

85101
In obfuscated code, fields with different types can have the same names,

build.gradle

Lines changed: 87 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,67 @@ allprojects {
66

77
buildscript {
88
if (System.properties['kotlinSnapshot'] != null) {
9-
ext.kotlin_version = '1.1-SNAPSHOT'
9+
ext.kotlin_version = '1.2-SNAPSHOT'
1010
repositories {
1111
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
1212
}
1313
}
1414
repositories {
1515
jcenter()
1616
maven { url "http://kotlin.bintray.com/kotlinx" }
17+
maven { url "http://kotlin.bintray.com/kotlin-dev" }
18+
maven { url "https://plugins.gradle.org/m2/" }
1719
}
1820
dependencies {
1921
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
2022
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
2123
classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version"
22-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
24+
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version"
25+
classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
2326
}
2427
}
2528

26-
// --------------- pom configuration ---------------
29+
// --------------- Configure sub-projects with Kotlin sources ---------------
2730

28-
def pomConfig = {
29-
licenses {
30-
license {
31-
name "The Apache Software License, Version 2.0"
32-
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
33-
distribution "repo"
34-
}
35-
}
36-
developers {
37-
developer {
38-
id "JetBrains"
39-
name "JetBrains Team"
40-
organization "JetBrains"
41-
organizationUrl "http://www.jetbrains.com"
42-
}
43-
}
31+
def sourceless = ['site']
4432

45-
scm {
46-
url "https://github.com/Kotlin/kotlinx.coroutines"
47-
}
33+
static def platformOf(project) {
34+
if (project.name.endsWith("-common")) return "common"
35+
if (project.name.endsWith("-js")) return "js"
36+
return "jvm"
4837
}
4938

50-
// --------------- Configure sub-projects with Kotlin sources ---------------
51-
52-
def sourceless = ['site']
39+
static def platformLib(base, platform) {
40+
if (platform == "jvm") return base
41+
return "$base-$platform"
42+
}
5343

5444
configure(subprojects.findAll { !sourceless.contains(it.name) }) {
55-
apply plugin: 'kotlin'
45+
def platform = platformOf(it)
46+
apply plugin: "kotlin-platform-$platform"
5647

57-
sourceCompatibility = 1.6
58-
targetCompatibility = 1.6
59-
60-
tasks.withType(JavaCompile) {
61-
options.encoding = 'UTF-8'
48+
if (platform == "jvm") {
49+
sourceCompatibility = 1.6
50+
targetCompatibility = 1.6
6251
}
63-
52+
6453
kotlin.experimental.coroutines "enable"
6554

55+
if (platform == "js") {
56+
tasks.withType(compileKotlin2Js.getClass()) {
57+
kotlinOptions {
58+
moduleKind = "umd"
59+
sourceMap = true
60+
metaInfo = true
61+
}
62+
}
63+
}
64+
6665
tasks.withType(Test) {
67-
testLogging.showStandardStreams = true
66+
testLogging {
67+
showStandardStreams = true
68+
events "passed", "failed"
69+
}
6870
def stressTest = project.properties['stressTest']
6971
if (stressTest != null) systemProperties['stressTest'] = stressTest
7072
}
@@ -75,17 +77,34 @@ configure(subprojects.findAll { !sourceless.contains(it.name) }) {
7577
maven { url "https://dl.bintray.com/devexperts/Maven/" }
7678
}
7779

80+
def kotlin_stdlib = platformLib("kotlin-stdlib", platform)
81+
def kotlin_test = platformLib("kotlin-test", platform)
82+
7883
dependencies {
79-
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
80-
testCompile "junit:junit:$junit_version"
84+
compile "org.jetbrains.kotlin:$kotlin_stdlib:$kotlin_version"
85+
testCompile "org.jetbrains.kotlin:$kotlin_test:$kotlin_version"
86+
}
87+
88+
if (platform == "common") {
89+
dependencies {
90+
testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"
91+
}
92+
}
93+
94+
if (platform == "jvm") {
95+
dependencies {
96+
testCompile "junit:junit:$junit_version"
97+
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
98+
}
8199
}
82100
}
83101

84102
// --------------- Configure sub-projects that are part of the library ---------------
85103

86-
def internal = sourceless + ['benchmarks', 'knit']
104+
def internal = sourceless + ['benchmarks', 'knit', 'js-stub']
87105

88-
configure(subprojects.findAll { !internal.contains(it.name) }) {
106+
// configure atomicfu for JVM modules
107+
configure(subprojects.findAll { !internal.contains(it.name) && platformOf(it) == "jvm" }) {
89108
apply plugin: 'kotlinx-atomicfu'
90109

91110
dependencies {
@@ -110,104 +129,53 @@ configure(subprojects.findAll { !internal.contains(it.name) }) {
110129
}
111130
}
112131

113-
configure(subprojects.findAll { !internal.contains(it.name) && it.name != 'kotlinx-coroutines-core'}) {
114-
dependencies {
115-
compile project(':kotlinx-coroutines-core')
116-
//the only way IDEA can resolve test classes
117-
testCompile project(':kotlinx-coroutines-core').sourceSets.test.output
132+
// configure dependencies on core
133+
configure(subprojects.findAll { !internal.contains(it.name) && it.name != 'kotlinx-coroutines-core-common'}) {
134+
def platform = platformOf(it)
135+
def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
136+
137+
if (it.name == coroutines_core) {
138+
dependencies {
139+
expectedBy project(':kotlinx-coroutines-core-common')
140+
}
141+
} else {
142+
dependencies {
143+
compile project(":$coroutines_core")
144+
//the only way IDEA can resolve test classes
145+
testCompile project(":$coroutines_core").sourceSets.test.output
146+
}
118147
}
119148
}
120149

121150
// --------------- Configure sub-projects that are published ---------------
122151

123-
def unpublished = internal + 'kotlinx-coroutines-rx-example'
152+
def unpublished = internal + ['kotlinx-coroutines-rx-example', 'example-frontend-js']
124153

125154
def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/"
126155
def core_docs_file = "$projectDir/core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list"
127156

128157
configure(subprojects.findAll { !unpublished.contains(it.name) }) {
129-
apply plugin: 'maven'
130-
apply plugin: 'maven-publish'
131-
apply plugin: 'org.jetbrains.dokka'
132-
apply plugin: 'com.jfrog.bintray'
133-
134-
dokka {
135-
outputFormat = 'kotlin-website'
136-
}
137-
138-
task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) {
139-
outputFormat = 'javadoc'
140-
outputDirectory = "$buildDir/javadoc"
141-
}
142-
143-
tasks.withType(org.jetbrains.dokka.gradle.DokkaTask) {
144-
jdkVersion = 8
145-
includes = ['README.md']
146-
linkMapping {
147-
def relPath = rootProject.projectDir.toPath().relativize(projectDir.toPath())
148-
dir = "$projectDir/src/main/kotlin"
149-
url = "http://github.com/kotlin/kotlinx.coroutines/tree/master/$relPath/src/main/kotlin"
150-
suffix = "#L"
151-
}
152-
}
153-
154-
task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
155-
classifier = 'javadoc'
156-
from "$buildDir/javadoc"
157-
}
158+
apply from: rootProject.file('gradle/dokka.gradle')
159+
apply from: rootProject.file('gradle/publish-bintray.gradle')
160+
}
158161

159-
task sourcesJar(type: Jar, dependsOn: classes) {
160-
classifier = 'sources'
161-
from sourceSets.main.allSource
162-
}
162+
configure(subprojects.findAll { !unpublished.contains(it.name) }) {
163+
def platform = platformOf(it)
164+
def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
163165

164-
publishing {
165-
publications {
166-
maven(MavenPublication) {
167-
from components.java
168-
artifact javadocJar
169-
artifact sourcesJar
170-
pom.withXml {
171-
def root = asNode()
172-
root.appendNode('name', project.name)
173-
root.appendNode('description', 'Coroutines support libraries for Kotlin')
174-
root.appendNode('url', 'https://github.com/Kotlin/kotlinx.coroutines')
175-
root.children().last() + pomConfig
176-
}
177-
}
178-
}
179-
}
166+
if (it.name != coroutines_core) {
167+
dokka.dependsOn project(":$coroutines_core").dokka
180168

181-
bintray {
182-
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
183-
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
184-
publications = ['maven']
185-
pkg {
186-
userOrg = 'kotlin'
187-
repo = 'kotlinx'
188-
name = 'kotlinx.coroutines'
189-
version {
190-
name = project.version
191-
vcsTag = project.version
192-
released = new Date()
169+
tasks.withType(dokka.getClass()) {
170+
externalDocumentationLink {
171+
url = new URL(core_docs_url)
172+
packageListUrl = new URL("file://$core_docs_file")
193173
}
194174
}
195175
}
196-
197-
bintrayUpload.doLast {
198-
println("Uploaded $project.name version $project.version")
199-
}
200-
}
201-
202-
configure(subprojects.findAll { !unpublished.contains(it.name) && it.name != 'kotlinx-coroutines-core' }) {
203-
dokka.dependsOn project(':kotlinx-coroutines-core').dokka
204-
dokkaJavadoc.dependsOn project(':kotlinx-coroutines-core').dokka
205-
206-
tasks.withType(org.jetbrains.dokka.gradle.DokkaTask) {
207-
externalDocumentationLink {
208-
url = new URL(core_docs_url)
209-
packageListUrl = new URL("file://$core_docs_file")
210-
}
176+
177+
if (platform == "jvm") {
178+
dokkaJavadoc.dependsOn project(":$coroutines_core").dokka
211179
}
212180
}
213181

0 commit comments

Comments
 (0)