Skip to content

Commit

Permalink
MPP: Added js-stub module to properly render Promise extension in Dokka
Browse files Browse the repository at this point in the history
  • Loading branch information
elizarov committed Dec 26, 2017
1 parent 4cdf883 commit a964799
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ configure(subprojects.findAll { !sourceless.contains(it.name) }) {

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

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

// configure atomicfu for JVM modules
configure(subprojects.findAll { !internal.contains(it.name) && platformOf(it) == "jvm" }) {
Expand Down
25 changes: 14 additions & 11 deletions gradle/dokka.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,38 @@ if (platform == "jvm") {
}

if (project.name == coroutines_core) {
// Configuration for MPP module
// Custom configuration for MPP modules
dependencies {
compileOnly project(":js-stub") // so that JS library reference can resolve properly
}

dokka {
kotlinTasks { [] }
suppressedModifiers = ['actual']
// map for JS & Common sources
makeLinkMapping(it, projectDir)
makeLinkMapping(it, rootProject.file('js/kotlinx-coroutines-core-js'))
makeLinkMapping(it, rootProject.file('common/kotlinx-coroutines-core-common'))
makeLinkMapping(it, rootProject.file("js/$project.name-js"))
makeLinkMapping(it, rootProject.file("common/$project.name-common"))
// source roots
impliedPlatforms = ['JVM', 'JS']
sourceRoot {
path = rootProject.file('core/kotlinx-coroutines-core/src/main/kotlin')
path = rootProject.file("core/$project.name/src/main/kotlin")
platforms = ['JVM']
}
sourceRoot {
path = rootProject.file('js/kotlinx-coroutines-core-js/src/main/kotlin')
path = rootProject.file("js/$project.name-js/src/main/kotlin")
platforms = ['JS']
}
sourceRoot {
path = rootProject.file('common/kotlinx-coroutines-core-common/src/main/kotlin')
path = rootProject.file("common/$project.name-common/src/main/kotlin")
}
// depends on JS & Common, too
afterEvaluate {
dependsOn(tasks.getByPath(":kotlinx-coroutines-core-js:classes"))
dependsOn(tasks.getByPath(":kotlinx-coroutines-core-common:classes"))
}
afterEvaluate {
classpath = project.configurations.compileClasspath.files
dependsOn(tasks.getByPath(":$project.name-js:classes"))
dependsOn(tasks.getByPath(":$project.name-common:classes"))
// dependsOn(tasks.getByPath(":js-stub:classes"))
dependsOn(project.configurations.compileClasspath)
classpath = project.configurations.compileClasspath.files
}
}
}
Expand Down
1 change: 1 addition & 0 deletions js/js-stub/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a workaround for Dokka to generate proper references for JS modules.
5 changes: 5 additions & 0 deletions js/js-stub/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
compileKotlin {
kotlinOptions {
freeCompilerArgs += "-Xallow-kotlin-package"
}
}
19 changes: 19 additions & 0 deletions js/js-stub/src/main/kotlin/Promise.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2016-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package kotlin.js

public open class Promise<out T>
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ include 'kotlinx-coroutines-javafx'
include 'kotlinx-coroutines-swing'

include 'kotlinx-coroutines-core-js'
include 'js-stub'

include 'benchmarks'
include 'knit'
Expand All @@ -42,3 +43,4 @@ project(':kotlinx-coroutines-android').projectDir = file('ui/kotlinx-coroutines-
project(':kotlinx-coroutines-javafx').projectDir = file('ui/kotlinx-coroutines-javafx')
project(':kotlinx-coroutines-swing').projectDir = file('ui/kotlinx-coroutines-swing')
project(':kotlinx-coroutines-core-js').projectDir = file('js/kotlinx-coroutines-core-js')
project(':js-stub').projectDir = file('js/js-stub')

0 comments on commit a964799

Please sign in to comment.