Roman Elizarov | 1f74a2d | 2018-06-29 19:19:45 +0300 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
| 3 | */ |
| 4 | |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 5 | // Configures generation of JavaDoc & Dokka artifacts |
| 6 | |
| 7 | def platform = platformOf(project) |
Roman Elizarov | e00f0ba | 2017-12-23 00:29:29 +0300 | [diff] [blame] | 8 | def coroutines_core = platformLib("kotlinx-coroutines-core", platform) |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 9 | |
Roman Elizarov | 4cdf883 | 2017-12-25 17:07:02 +0300 | [diff] [blame] | 10 | def makeLinkMapping(dokka, projectDir) { |
| 11 | dokka.linkMapping { |
| 12 | def relPath = rootProject.projectDir.toPath().relativize(projectDir.toPath()) |
| 13 | dir = "$projectDir/src/main/kotlin" |
Vsevolod Tolstopyatov | c1eb19f | 2018-06-19 17:04:09 +0300 | [diff] [blame] | 14 | url = "http://github.com/kotlin/kotlinx.coroutines/tree/master/$relPath/src" |
Roman Elizarov | 4cdf883 | 2017-12-25 17:07:02 +0300 | [diff] [blame] | 15 | suffix = "#L" |
| 16 | } |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | if (platform == "jvm") { |
Roman Elizarov | 4cdf883 | 2017-12-25 17:07:02 +0300 | [diff] [blame] | 20 | apply plugin: 'org.jetbrains.dokka' |
| 21 | |
| 22 | tasks.withType(dokka.getClass()) { |
| 23 | jdkVersion = 8 |
| 24 | includes = ['README.md'] |
| 25 | } |
| 26 | |
| 27 | dokka { |
| 28 | outputFormat = 'kotlin-website' |
| 29 | } |
| 30 | |
| 31 | if (project.name == coroutines_core) { |
Roman Elizarov | a964799 | 2017-12-26 13:09:43 +0300 | [diff] [blame] | 32 | // Custom configuration for MPP modules |
| 33 | dependencies { |
| 34 | compileOnly project(":js-stub") // so that JS library reference can resolve properly |
| 35 | } |
| 36 | |
Roman Elizarov | 4cdf883 | 2017-12-25 17:07:02 +0300 | [diff] [blame] | 37 | dokka { |
| 38 | kotlinTasks { [] } |
| 39 | suppressedModifiers = ['actual'] |
| 40 | // map for JS & Common sources |
| 41 | makeLinkMapping(it, projectDir) |
Roman Elizarov | a964799 | 2017-12-26 13:09:43 +0300 | [diff] [blame] | 42 | makeLinkMapping(it, rootProject.file("js/$project.name-js")) |
| 43 | makeLinkMapping(it, rootProject.file("common/$project.name-common")) |
Roman Elizarov | 4cdf883 | 2017-12-25 17:07:02 +0300 | [diff] [blame] | 44 | // source roots |
| 45 | impliedPlatforms = ['JVM', 'JS'] |
| 46 | sourceRoot { |
Vsevolod Tolstopyatov | c1eb19f | 2018-06-19 17:04:09 +0300 | [diff] [blame] | 47 | path = rootProject.file("core/$project.name/src") |
Roman Elizarov | 4cdf883 | 2017-12-25 17:07:02 +0300 | [diff] [blame] | 48 | platforms = ['JVM'] |
| 49 | } |
| 50 | sourceRoot { |
Vsevolod Tolstopyatov | c1eb19f | 2018-06-19 17:04:09 +0300 | [diff] [blame] | 51 | path = rootProject.file("js/$project.name-js/src") |
Roman Elizarov | 4cdf883 | 2017-12-25 17:07:02 +0300 | [diff] [blame] | 52 | platforms = ['JS'] |
| 53 | } |
| 54 | sourceRoot { |
Vsevolod Tolstopyatov | c1eb19f | 2018-06-19 17:04:09 +0300 | [diff] [blame] | 55 | path = rootProject.file("common/$project.name-common/src") |
Roman Elizarov | 4cdf883 | 2017-12-25 17:07:02 +0300 | [diff] [blame] | 56 | } |
| 57 | // depends on JS & Common, too |
| 58 | afterEvaluate { |
Roman Elizarov | 09ca3b6 | 2018-01-29 21:27:47 +0300 | [diff] [blame] | 59 | dependsOn(tasks.getByPath(":$project.name:classes")) |
Roman Elizarov | a964799 | 2017-12-26 13:09:43 +0300 | [diff] [blame] | 60 | dependsOn(tasks.getByPath(":$project.name-js:classes")) |
| 61 | dependsOn(tasks.getByPath(":$project.name-common:classes")) |
Roman Elizarov | 4cdf883 | 2017-12-25 17:07:02 +0300 | [diff] [blame] | 62 | dependsOn(project.configurations.compileClasspath) |
Roman Elizarov | 415df7e | 2018-01-29 17:35:40 +0300 | [diff] [blame] | 63 | classpath = project.configurations.compileClasspath.files + project.sourceSets.main.output.files |
Roman Elizarov | 4cdf883 | 2017-12-25 17:07:02 +0300 | [diff] [blame] | 64 | } |
| 65 | } |
| 66 | } |
| 67 | |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 68 | // real xxx-javadoc.jar for JVM |
| 69 | task dokkaJavadoc(type: dokka.getClass()) { |
| 70 | outputFormat = 'javadoc' |
| 71 | outputDirectory = "$buildDir/javadoc" |
| 72 | } |
| 73 | |
| 74 | task javadocJar(type: Jar, dependsOn: dokkaJavadoc) { |
| 75 | classifier = 'javadoc' |
| 76 | from "$buildDir/javadoc" |
| 77 | } |
| 78 | } else { |
Roman Elizarov | 4cdf883 | 2017-12-25 17:07:02 +0300 | [diff] [blame] | 79 | // empty xxx-javadoc.jar for JS and Common modules |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 80 | task javadocJar(type: Jar) { |
| 81 | classifier = 'javadoc' |
| 82 | from "$buildDir/javadoc" // would not exist |
| 83 | } |
| 84 | } |