Skip to content

Commit 498a6d8

Browse files
committed
Use a separate Knit tool version 0.1.0
* Hierarchical knit.properties files are introduced which are gathered while walking up the directory tree with the properties in knit resources being top-level ones. * Freemarker templates for "knit.include" (top-level of example files) and "test.template" (test template) are introduced with locations that are resolved from properties. * KNIT and TEST_OUT directives are not supported anymore. - Knitting is controlled by "knit.dir" and "knit.pattern" props. - "test.name" prop or TEST_NAME directive drives test gen. * All markdown files are now clean of top-level knit-related boilerplate (only TEST_NAME directive is remaining in some) * All example files are renumbered. It affects example-basic-xx, which had the legacy numbering with later insertions. * All auto-generated files now have the correct source-file name specified at their beginning, due to consistent use of template substitution. * No need to customize knit.pattern anymore (works out-of-the box) * "knit.name" is automatically generated based on example's file name "example-basic-01" -> "exampleBasic01" * Not match-pattern-group woodoo anymore, "knit.pattern" cannot have any user-defined match groups. * No need to look for "package xxx" in knitted sources, as the example's package is always ${knit.package}.${knit.name} * Simpler test names: testKotlinxCoroutinesGuideBasic01 -> testExampleBasic01 * Replaced END_TOC with END directive * Build-scripts are improved: - Consistent code to use mavenLocal when snapshots versions are used. - Proper substitution logic to use Android AAR files so that Dokka has correct links to Google APIs. - Google repository is added to all projects.
1 parent 09cb4bf commit 498a6d8

File tree

156 files changed

+886
-1623
lines changed

Some content is hidden

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

156 files changed

+886
-1623
lines changed

build.gradle

+13-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ apply from: rootProject.file("gradle/experimental.gradle")
88
def rootModule = "kotlinx.coroutines"
99
def coreModule = "kotlinx-coroutines-core"
1010
// Not applicable for Kotlin plugin
11-
def sourceless = ['kotlinx.coroutines', 'site', 'kotlinx-coroutines-bom']
11+
def sourceless = ['kotlinx.coroutines', 'site', 'kotlinx-coroutines-bom', 'knit']
1212
def internal = ['kotlinx.coroutines', 'site', 'benchmarks', 'knit', 'js-stub', 'stdlib-stubs', 'binary-compatibility-validator']
1313
// Not published
1414
def unpublished = internal + ['example-frontend-js', 'android-unit-tests']
@@ -41,7 +41,15 @@ buildscript {
4141
}
4242
}
4343

44-
if (build_snapshot_train || atomicfu_version.endsWith("-SNAPSHOT")) {
44+
ext.using_snapshot_version=build_snapshot_train
45+
rootProject.properties.each { key, value ->
46+
if (key.endsWith("_version") && value instanceof String && value.endsWith("-SNAPSHOT")) {
47+
println("NOTE: USING SNAPSHOT VERSION: $key=$value")
48+
ext.using_snapshot_version=true
49+
}
50+
}
51+
52+
if (using_snapshot_version) {
4553
repositories {
4654
mavenLocal()
4755
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
@@ -67,6 +75,7 @@ buildscript {
6775
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
6876
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
6977
classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfu_version"
78+
classpath "org.jetbrains.kotlinx:kotlinx-knit:$knit_version"
7079
classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
7180

7281
// JMH plugins
@@ -101,7 +110,7 @@ allprojects {
101110
kotlin_version = rootProject.properties['kotlin_snapshot_version']
102111
}
103112

104-
if (build_snapshot_train || atomicfu_version.endsWith("-SNAPSHOT") || lincheck_version.endsWith("-SNAPSHOT")) {
113+
if (using_snapshot_version) {
105114
repositories {
106115
mavenLocal()
107116
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
@@ -127,9 +136,7 @@ allprojects {
127136
* google should be first in the repository list because some of the play services
128137
* transitive dependencies was removed from jcenter, thus breaking gradle dependency resolution
129138
*/
130-
if (projectName == "kotlinx-coroutines-play-services") {
131-
google()
132-
}
139+
google()
133140
jcenter()
134141
maven {
135142
url "https://kotlin.bintray.com/kotlin-dev"

docs/basics.md

+9-26
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
1-
<!--- INCLUDE .*/example-([a-z]+)-([0-9a-z]+)\.kt
2-
/*
3-
* Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
4-
*/
5-
6-
// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
7-
package kotlinx.coroutines.guide.$$1$$2
8-
-->
9-
<!--- KNIT ../kotlinx-coroutines-core/jvm/test/guide/.*\.kt -->
10-
<!--- TEST_OUT ../kotlinx-coroutines-core/jvm/test/guide/test/BasicsGuideTest.kt
11-
// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
12-
package kotlinx.coroutines.guide.test
13-
14-
import org.junit.Test
15-
16-
class BasicsGuideTest {
17-
-->
1+
<!--- TEST_NAME BasicsGuideTest -->
182

193
**Table of contents**
204

@@ -30,8 +14,7 @@ class BasicsGuideTest {
3014
* [Coroutines ARE light-weight](#coroutines-are-light-weight)
3115
* [Global coroutines are like daemon threads](#global-coroutines-are-like-daemon-threads)
3216

33-
<!--- END_TOC -->
34-
17+
<!--- END -->
3518

3619
## Coroutine Basics
3720

@@ -142,7 +125,7 @@ fun main() = runBlocking<Unit> { // start main coroutine
142125

143126
</div>
144127

145-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-02b.kt).
128+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-03.kt).
146129
147130
<!--- TEST
148131
Hello,
@@ -197,7 +180,7 @@ fun main() = runBlocking {
197180

198181
</div>
199182

200-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-03.kt).
183+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-04.kt).
201184
202185
<!--- TEST
203186
Hello,
@@ -242,7 +225,7 @@ fun main() = runBlocking { // this: CoroutineScope
242225

243226
</div>
244227

245-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-03s.kt).
228+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-05.kt).
246229
247230
<!--- TEST
248231
Hello,
@@ -288,7 +271,7 @@ fun main() = runBlocking { // this: CoroutineScope
288271

289272
</div>
290273

291-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-04.kt).
274+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-06.kt).
292275
293276
<!--- TEST
294277
Task from coroutine scope
@@ -327,7 +310,7 @@ suspend fun doWorld() {
327310

328311
</div>
329312

330-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-05.kt).
313+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-07.kt).
331314
332315
<!--- TEST
333316
Hello,
@@ -364,7 +347,7 @@ fun main() = runBlocking {
364347

365348
</div>
366349

367-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-06.kt).
350+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-08.kt).
368351
369352
<!--- TEST lines.size == 1 && lines[0] == ".".repeat(100_000) -->
370353

@@ -396,7 +379,7 @@ fun main() = runBlocking {
396379

397380
</div>
398381

399-
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-07.kt).
382+
> You can get full code [here](../kotlinx-coroutines-core/jvm/test/guide/example-basic-09.kt).
400383
401384
You can run and see that it prints three lines and terminates:
402385

docs/cancellation-and-timeouts.md

+2-17
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
1-
<!--- INCLUDE .*/example-([a-z]+)-([0-9a-z]+)\.kt
2-
/*
3-
* Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
4-
*/
1+
<!--- TEST_NAME CancellationGuideTest -->
52

6-
// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
7-
package kotlinx.coroutines.guide.$$1$$2
8-
-->
9-
<!--- KNIT ../kotlinx-coroutines-core/jvm/test/guide/.*\.kt -->
10-
<!--- TEST_OUT ../kotlinx-coroutines-core/jvm/test/guide/test/CancellationTimeOutsGuideTest.kt
11-
// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
12-
package kotlinx.coroutines.guide.test
13-
14-
import org.junit.Test
15-
16-
class CancellationTimeOutsGuideTest {
17-
-->
183
**Table of contents**
194

205
<!--- TOC -->
@@ -27,7 +12,7 @@ class CancellationTimeOutsGuideTest {
2712
* [Run non-cancellable block](#run-non-cancellable-block)
2813
* [Timeout](#timeout)
2914

30-
<!--- END_TOC -->
15+
<!--- END -->
3116

3217
## Cancellation and Timeouts
3318

docs/channels.md

+2-17
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
1-
<!--- INCLUDE .*/example-([a-z]+)-([0-9a-z]+)\.kt
2-
/*
3-
* Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
4-
*/
1+
<!--- TEST_NAME ChannelsGuideTest -->
52

6-
// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
7-
package kotlinx.coroutines.guide.$$1$$2
8-
-->
9-
<!--- KNIT ../kotlinx-coroutines-core/jvm/test/guide/.*\.kt -->
10-
<!--- TEST_OUT ../kotlinx-coroutines-core/jvm/test/guide/test/ChannelsGuideTest.kt
11-
// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
12-
package kotlinx.coroutines.guide.test
13-
14-
import org.junit.Test
15-
16-
class ChannelsGuideTest {
17-
-->
183
**Table of contents**
194

205
<!--- TOC -->
@@ -31,7 +16,7 @@ class ChannelsGuideTest {
3116
* [Channels are fair](#channels-are-fair)
3217
* [Ticker channels](#ticker-channels)
3318

34-
<!--- END_TOC -->
19+
<!--- END -->
3520

3621
## Channels
3722

docs/compatibility.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
<!---
2-
/*
3-
* Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
4-
*/
5-
--->
6-
71
<!--- TOC -->
82

93
* [Compatibility](#compatibility)
@@ -19,7 +13,7 @@
1913
* [Gradle](#gradle)
2014
* [Maven](#maven)
2115

22-
<!--- END_TOC -->
16+
<!--- END -->
2317

2418
## Compatibility
2519
This document describes the compatibility policy of `kotlinx.coroutines` library since version 1.0.0 and semantics of compatibility-specific annotations.

docs/composing-suspending-functions.md

+2-18
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
1-
<!--- INCLUDE .*/example-([a-z]+)-([0-9a-z]+)\.kt
2-
/*
3-
* Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
4-
*/
5-
6-
// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
7-
package kotlinx.coroutines.guide.$$1$$2
8-
-->
9-
<!--- KNIT ../kotlinx-coroutines-core/jvm/test/guide/.*\.kt -->
10-
<!--- TEST_OUT ../kotlinx-coroutines-core/jvm/test/guide/test/ComposingGuideTest.kt
11-
// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
12-
package kotlinx.coroutines.guide.test
13-
14-
import org.junit.Test
15-
16-
class ComposingGuideTest {
17-
-->
1+
<!--- TEST_NAME ComposingGuideTest -->
182

193
**Table of contents**
204

@@ -27,7 +11,7 @@ class ComposingGuideTest {
2711
* [Async-style functions](#async-style-functions)
2812
* [Structured concurrency with async](#structured-concurrency-with-async)
2913

30-
<!--- END_TOC -->
14+
<!--- END -->
3115

3216
## Composing Suspending Functions
3317

docs/coroutine-context-and-dispatchers.md

+2-18
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
1-
<!--- INCLUDE .*/example-([a-z]+)-([0-9a-z]+)\.kt
2-
/*
3-
* Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
4-
*/
5-
6-
// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
7-
package kotlinx.coroutines.guide.$$1$$2
8-
-->
9-
<!--- KNIT ../kotlinx-coroutines-core/jvm/test/guide/.*\.kt -->
10-
<!--- TEST_OUT ../kotlinx-coroutines-core/jvm/test/guide/test/DispatcherGuideTest.kt
11-
// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
12-
package kotlinx.coroutines.guide.test
13-
14-
import org.junit.Test
15-
16-
class DispatchersGuideTest {
17-
-->
1+
<!--- TEST_NAME DispatcherGuideTest -->
182

193
**Table of contents**
204

@@ -33,7 +17,7 @@ class DispatchersGuideTest {
3317
* [Coroutine scope](#coroutine-scope)
3418
* [Thread-local data](#thread-local-data)
3519

36-
<!--- END_TOC -->
20+
<!--- END -->
3721

3822
## Coroutine Context and Dispatchers
3923

docs/debugging.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
* [Debug agent](#debug-agent)
1010
* [Debug agent and Android](#debug-agent-and-android)
1111

12-
<!--- END_TOC -->
13-
12+
<!--- END -->
1413

1514
## Debugging coroutines
1615
Debugging asynchronous programs is challenging, because multiple concurrent coroutines are typically working at the same time.

docs/exception-handling.md

+2-18
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
1-
<!--- INCLUDE .*/example-([a-z]+)-([0-9a-z]+)\.kt
2-
/*
3-
* Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
4-
*/
1+
<!--- TEST_NAME ExceptionsGuideTest -->
52

6-
// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
7-
package kotlinx.coroutines.guide.$$1$$2
8-
-->
9-
<!--- KNIT ../kotlinx-coroutines-core/jvm/test/guide/.*\.kt -->
10-
<!--- TEST_OUT ../kotlinx-coroutines-core/jvm/test/guide/test/ExceptionsGuideTest.kt
11-
// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
12-
package kotlinx.coroutines.guide.test
13-
14-
import org.junit.Test
15-
16-
class ExceptionsGuideTest {
17-
-->
183
**Table of contents**
194

205
<!--- TOC -->
@@ -29,7 +14,7 @@ class ExceptionsGuideTest {
2914
* [Supervision scope](#supervision-scope)
3015
* [Exceptions in supervised coroutines](#exceptions-in-supervised-coroutines)
3116

32-
<!--- END_TOC -->
17+
<!--- END -->
3318

3419
## Exception Handling
3520

@@ -260,7 +245,6 @@ to leak to its exception handler.
260245

261246

262247
<!--- INCLUDE
263-
264248
import kotlinx.coroutines.exceptions.*
265249
-->
266250

docs/flow.md

+2-18
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
1-
<!--- INCLUDE .*/example-([a-z]+)-([0-9a-z]+)\.kt
2-
/*
3-
* Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
4-
*/
5-
6-
// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
7-
package kotlinx.coroutines.guide.$$1$$2
8-
-->
9-
<!--- KNIT ../kotlinx-coroutines-core/jvm/test/guide/.*-##\.kt -->
10-
<!--- TEST_OUT ../kotlinx-coroutines-core/jvm/test/guide/test/FlowGuideTest.kt
11-
// This file was automatically generated from flow.md by Knit tool. Do not edit.
12-
package kotlinx.coroutines.guide.test
13-
14-
import org.junit.Test
15-
16-
class FlowGuideTest {
17-
-->
1+
<!--- TEST_NAME FlowGuideTest -->
182

193
**Table of contents**
204

@@ -60,7 +44,7 @@ class FlowGuideTest {
6044
* [Launching flow](#launching-flow)
6145
* [Flow and Reactive Streams](#flow-and-reactive-streams)
6246

63-
<!--- END_TOC -->
47+
<!--- END -->
6448

6549
## Asynchronous Flow
6650

docs/knit.properties

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
#
4+
5+
knit.package=kotlinx.coroutines.guide
6+
knit.dir=../kotlinx-coroutines-core/jvm/test/guide/
7+
8+
test.package=kotlinx.coroutines.guide.test
9+
test.dir=../kotlinx-coroutines-core/jvm/test/guide/test/

0 commit comments

Comments
 (0)