Skip to content

Commit a964799

Browse files
committed
MPP: Added js-stub module to properly render Promise extension in Dokka
1 parent 4cdf883 commit a964799

File tree

6 files changed

+42
-12
lines changed

6 files changed

+42
-12
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ configure(subprojects.findAll { !sourceless.contains(it.name) }) {
9595

9696
// --------------- Configure sub-projects that are part of the library ---------------
9797

98-
def internal = sourceless + ['benchmarks', 'knit']
98+
def internal = sourceless + ['benchmarks', 'knit', 'js-stub']
9999

100100
// configure atomicfu for JVM modules
101101
configure(subprojects.findAll { !internal.contains(it.name) && platformOf(it) == "jvm" }) {

gradle/dokka.gradle

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,38 @@ if (platform == "jvm") {
2525
}
2626

2727
if (project.name == coroutines_core) {
28-
// Configuration for MPP module
28+
// Custom configuration for MPP modules
29+
dependencies {
30+
compileOnly project(":js-stub") // so that JS library reference can resolve properly
31+
}
32+
2933
dokka {
3034
kotlinTasks { [] }
3135
suppressedModifiers = ['actual']
3236
// map for JS & Common sources
3337
makeLinkMapping(it, projectDir)
34-
makeLinkMapping(it, rootProject.file('js/kotlinx-coroutines-core-js'))
35-
makeLinkMapping(it, rootProject.file('common/kotlinx-coroutines-core-common'))
38+
makeLinkMapping(it, rootProject.file("js/$project.name-js"))
39+
makeLinkMapping(it, rootProject.file("common/$project.name-common"))
3640
// source roots
3741
impliedPlatforms = ['JVM', 'JS']
3842
sourceRoot {
39-
path = rootProject.file('core/kotlinx-coroutines-core/src/main/kotlin')
43+
path = rootProject.file("core/$project.name/src/main/kotlin")
4044
platforms = ['JVM']
4145
}
4246
sourceRoot {
43-
path = rootProject.file('js/kotlinx-coroutines-core-js/src/main/kotlin')
47+
path = rootProject.file("js/$project.name-js/src/main/kotlin")
4448
platforms = ['JS']
4549
}
4650
sourceRoot {
47-
path = rootProject.file('common/kotlinx-coroutines-core-common/src/main/kotlin')
51+
path = rootProject.file("common/$project.name-common/src/main/kotlin")
4852
}
4953
// depends on JS & Common, too
5054
afterEvaluate {
51-
dependsOn(tasks.getByPath(":kotlinx-coroutines-core-js:classes"))
52-
dependsOn(tasks.getByPath(":kotlinx-coroutines-core-common:classes"))
53-
}
54-
afterEvaluate {
55-
classpath = project.configurations.compileClasspath.files
55+
dependsOn(tasks.getByPath(":$project.name-js:classes"))
56+
dependsOn(tasks.getByPath(":$project.name-common:classes"))
57+
// dependsOn(tasks.getByPath(":js-stub:classes"))
5658
dependsOn(project.configurations.compileClasspath)
59+
classpath = project.configurations.compileClasspath.files
5760
}
5861
}
5962
}

js/js-stub/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a workaround for Dokka to generate proper references for JS modules.

js/js-stub/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
compileKotlin {
2+
kotlinOptions {
3+
freeCompilerArgs += "-Xallow-kotlin-package"
4+
}
5+
}

js/js-stub/src/main/kotlin/Promise.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright 2016-2017 JetBrains s.r.o.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package kotlin.js
18+
19+
public open class Promise<out T>

settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ include 'kotlinx-coroutines-javafx'
2121
include 'kotlinx-coroutines-swing'
2222

2323
include 'kotlinx-coroutines-core-js'
24+
include 'js-stub'
2425

2526
include 'benchmarks'
2627
include 'knit'
@@ -42,3 +43,4 @@ project(':kotlinx-coroutines-android').projectDir = file('ui/kotlinx-coroutines-
4243
project(':kotlinx-coroutines-javafx').projectDir = file('ui/kotlinx-coroutines-javafx')
4344
project(':kotlinx-coroutines-swing').projectDir = file('ui/kotlinx-coroutines-swing')
4445
project(':kotlinx-coroutines-core-js').projectDir = file('js/kotlinx-coroutines-core-js')
46+
project(':js-stub').projectDir = file('js/js-stub')

0 commit comments

Comments
 (0)