Roman Elizarov | 1f74a2d | 2018-06-29 19:19:45 +0300 | [diff] [blame] | 1 | /* |
Vsevolod Tolstopyatov | 0e926e7 | 2021-01-18 08:47:09 -0800 | [diff] [blame] | 2 | * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
Roman Elizarov | 1f74a2d | 2018-06-29 19:19:45 +0300 | [diff] [blame] | 3 | */ |
Vsevolod Tolstopyatov | 1392686 | 2021-06-07 16:24:21 +0300 | [diff] [blame] | 4 | |
| 5 | import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 6 | import org.jetbrains.kotlin.konan.target.HostManager |
Vsevolod Tolstopyatov | bcbcd16 | 2021-07-06 14:29:27 +0300 | [diff] [blame] | 7 | import org.gradle.util.VersionNumber |
| 8 | import org.jetbrains.dokka.gradle.DokkaTaskPartial |
| 9 | import org.jetbrains.dokka.gradle.DokkaMultiModuleTask |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 10 | |
Victor Turansky | e47cb35 | 2020-05-12 18:33:04 +0300 | [diff] [blame] | 11 | apply plugin: 'jdk-convention' |
Vsevolod Tolstopyatov | f5e8740 | 2021-07-08 13:47:21 +0300 | [diff] [blame] | 12 | apply from: rootProject.file("gradle/opt-in.gradle") |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 13 | |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 14 | def coreModule = "kotlinx-coroutines-core" |
| 15 | // Not applicable for Kotlin plugin |
Vsevolod Tolstopyatov | bcbcd16 | 2021-07-06 14:29:27 +0300 | [diff] [blame] | 16 | def sourceless = ['kotlinx.coroutines', 'kotlinx-coroutines-bom', 'integration-testing'] |
| 17 | def internal = ['kotlinx.coroutines', 'benchmarks', 'integration-testing'] |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 18 | // Not published |
Vsevolod Tolstopyatov | 5378b80 | 2019-09-19 17:39:08 +0300 | [diff] [blame] | 19 | def unpublished = internal + ['example-frontend-js', 'android-unit-tests'] |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 20 | |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 21 | buildscript { |
Vsevolod Tolstopyatov | 585b766 | 2019-04-16 12:10:57 +0300 | [diff] [blame] | 22 | /* |
| 23 | * These property group is used to build kotlinx.coroutines against Kotlin compiler snapshot. |
| 24 | * How does it work: |
| 25 | * When build_snapshot_train is set to true, kotlin_version property is overridden with kotlin_snapshot_version, |
| 26 | * atomicfu_version is overwritten by TeamCity environment (AFU is built with snapshot and published to mavenLocal |
| 27 | * as previous step or the snapshot build). |
| 28 | * Additionally, mavenLocal and Sonatype snapshots are added to repository list and stress tests are disabled. |
| 29 | * DO NOT change the name of these properties without adapting kotlinx.train build chain. |
| 30 | */ |
| 31 | def prop = rootProject.properties['build_snapshot_train'] |
| 32 | ext.build_snapshot_train = prop != null && prop != "" |
| 33 | if (build_snapshot_train) { |
| 34 | ext.kotlin_version = rootProject.properties['kotlin_snapshot_version'] |
| 35 | if (kotlin_version == null) { |
| 36 | throw new IllegalArgumentException("'kotlin_snapshot_version' should be defined when building with snapshot compiler") |
| 37 | } |
Roman Elizarov | e1ac2e5 | 2019-04-19 18:51:05 +0300 | [diff] [blame] | 38 | } |
Alexander Likhachev | 179f142 | 2020-11-18 17:54:33 +0300 | [diff] [blame] | 39 | ext.native_targets_enabled = rootProject.properties['disable_native_targets'] == null |
Roman Elizarov | e1ac2e5 | 2019-04-19 18:51:05 +0300 | [diff] [blame] | 40 | |
Roman Elizarov | 660c2d7 | 2020-02-14 13:18:37 +0300 | [diff] [blame] | 41 | // Determine if any project dependency is using a snapshot version |
| 42 | ext.using_snapshot_version = build_snapshot_train |
| 43 | rootProject.properties.each { key, value -> |
| 44 | if (key.endsWith("_version") && value instanceof String && value.endsWith("-SNAPSHOT")) { |
| 45 | println("NOTE: USING SNAPSHOT VERSION: $key=$value") |
Vsevolod Tolstopyatov | bcbcd16 | 2021-07-06 14:29:27 +0300 | [diff] [blame] | 46 | ext.using_snapshot_version = true |
Roman Elizarov | 660c2d7 | 2020-02-14 13:18:37 +0300 | [diff] [blame] | 47 | } |
| 48 | } |
| 49 | |
| 50 | if (using_snapshot_version) { |
Roman Elizarov | 1f6b44d | 2017-10-26 17:51:52 +0300 | [diff] [blame] | 51 | repositories { |
Vsevolod Tolstopyatov | 585b766 | 2019-04-16 12:10:57 +0300 | [diff] [blame] | 52 | mavenLocal() |
Roman Elizarov | 1f6b44d | 2017-10-26 17:51:52 +0300 | [diff] [blame] | 53 | } |
| 54 | } |
Roman Elizarov | e1ac2e5 | 2019-04-19 18:51:05 +0300 | [diff] [blame] | 55 | |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 56 | repositories { |
Vsevolod Tolstopyatov | 69c3ce3 | 2021-07-08 18:47:54 +0300 | [diff] [blame^] | 57 | mavenCentral() |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 58 | maven { url "https://plugins.gradle.org/m2/" } |
Vsevolod Tolstopyatov | f2940d5 | 2021-03-22 16:11:06 +0300 | [diff] [blame] | 59 | maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" } |
Vsevolod Tolstopyatov | bcbcd16 | 2021-07-06 14:29:27 +0300 | [diff] [blame] | 60 | mavenLocal() |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 61 | } |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 62 | |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 63 | dependencies { |
| 64 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" |
| 65 | classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" |
Vsevolod Tolstopyatov | 585b766 | 2019-04-16 12:10:57 +0300 | [diff] [blame] | 66 | classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfu_version" |
Roman Elizarov | 660c2d7 | 2020-02-14 13:18:37 +0300 | [diff] [blame] | 67 | classpath "org.jetbrains.kotlinx:kotlinx-knit:$knit_version" |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 68 | classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version" |
Vsevolod Tolstopyatov | e153863 | 2020-02-10 21:12:58 +0300 | [diff] [blame] | 69 | classpath "org.jetbrains.kotlinx:binary-compatibility-validator:$binary_compatibility_validator_version" |
Vsevolod Tolstopyatov | 305c66a | 2018-08-21 21:01:58 +0300 | [diff] [blame] | 70 | |
| 71 | // JMH plugins |
Vsevolod Tolstopyatov | bda9c79 | 2019-09-12 16:50:33 +0300 | [diff] [blame] | 72 | classpath "com.github.jengelman.gradle.plugins:shadow:5.1.0" |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 73 | } |
Roman Elizarov | 85b1a2b | 2020-09-14 17:48:17 +0300 | [diff] [blame] | 74 | |
| 75 | CacheRedirector.configureBuildScript(buildscript, rootProject) |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 76 | } |
Roman Elizarov | 738f5a2 | 2020-10-12 19:03:46 +0300 | [diff] [blame] | 77 | // todo:KLUDGE: Hierarchical project structures are not fully supported in IDEA, enable only for a regular built |
| 78 | if (!Idea.active) { |
Sergey Igushkin | 17248c8 | 2020-05-22 12:28:25 +0300 | [diff] [blame] | 79 | ext.set("kotlin.mpp.enableGranularSourceSetsMetadata", "true") |
| 80 | } |
| 81 | |
Roman Elizarov | d2f4b2b | 2019-09-02 17:22:39 +0300 | [diff] [blame] | 82 | // todo:KLUDGE: This is needed to workaround dependency resolution between Java and MPP modules |
| 83 | def configureKotlinJvmPlatform(configuration) { |
| 84 | configuration.attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.jvm) |
| 85 | } |
| 86 | |
Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 87 | allprojects { |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 88 | // the only place where HostManager could be instantiated |
| 89 | project.ext.hostManager = new HostManager() |
Vsevolod Tolstopyatov | 585b766 | 2019-04-16 12:10:57 +0300 | [diff] [blame] | 90 | def deployVersion = properties['DeployVersion'] |
| 91 | if (deployVersion != null) version = deployVersion |
| 92 | |
| 93 | if (build_snapshot_train) { |
| 94 | ext.kotlin_version = rootProject.properties['kotlin_snapshot_version'] |
| 95 | println "Using Kotlin $kotlin_version for project $it" |
| 96 | |
Vsevolod Tolstopyatov | 6ca6ed5 | 2019-08-21 17:08:34 +0300 | [diff] [blame] | 97 | def skipSnapshotChecks = rootProject.properties['skip_snapshot_checks'] != null |
| 98 | if (!skipSnapshotChecks && version != atomicfu_version) { |
Vsevolod Tolstopyatov | 585b766 | 2019-04-16 12:10:57 +0300 | [diff] [blame] | 99 | throw new IllegalStateException("Current deploy version is $version, but atomicfu version is not overridden ($atomicfu_version) for $it") |
| 100 | } |
| 101 | |
| 102 | kotlin_version = rootProject.properties['kotlin_snapshot_version'] |
Roman Elizarov | e1ac2e5 | 2019-04-19 18:51:05 +0300 | [diff] [blame] | 103 | } |
| 104 | |
Roman Elizarov | 660c2d7 | 2020-02-14 13:18:37 +0300 | [diff] [blame] | 105 | if (using_snapshot_version) { |
Vsevolod Tolstopyatov | 585b766 | 2019-04-16 12:10:57 +0300 | [diff] [blame] | 106 | repositories { |
| 107 | mavenLocal() |
| 108 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" } |
| 109 | } |
| 110 | } |
Vsevolod Tolstopyatov | fe4e05c | 2019-07-19 12:28:15 +0300 | [diff] [blame] | 111 | |
| 112 | ext.unpublished = unpublished |
Roman Elizarov | 0b16abf | 2019-09-03 11:07:11 +0300 | [diff] [blame] | 113 | |
| 114 | // This project property is set during nightly stress test |
| 115 | def stressTest = project.properties['stressTest'] |
| 116 | |
| 117 | // Copy it to all test tasks |
| 118 | tasks.withType(Test) { |
| 119 | systemProperty 'stressTest', stressTest |
| 120 | } |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 121 | } |
| 122 | |
Vsevolod Tolstopyatov | e153863 | 2020-02-10 21:12:58 +0300 | [diff] [blame] | 123 | apply plugin: "binary-compatibility-validator" |
| 124 | apiValidation { |
dkhalanskyjb | 3651276 | 2020-02-21 17:31:05 +0300 | [diff] [blame] | 125 | ignoredProjects += unpublished + ["kotlinx-coroutines-bom"] |
Vsevolod Tolstopyatov | aff8202 | 2020-03-10 19:58:36 +0300 | [diff] [blame] | 126 | if (build_snapshot_train) { |
Vsevolod Tolstopyatov | aff8202 | 2020-03-10 19:58:36 +0300 | [diff] [blame] | 127 | ignoredProjects.remove("example-frontend-js") |
Stanislav Erokhin | 4b16e1b | 2020-06-09 09:38:51 +0300 | [diff] [blame] | 128 | ignoredProjects.add("kotlinx-coroutines-core") |
Vsevolod Tolstopyatov | aff8202 | 2020-03-10 19:58:36 +0300 | [diff] [blame] | 129 | } |
Vsevolod Tolstopyatov | e153863 | 2020-02-10 21:12:58 +0300 | [diff] [blame] | 130 | ignoredPackages += "kotlinx.coroutines.internal" |
| 131 | } |
| 132 | |
Roman Elizarov | bf9509d | 2020-02-14 15:52:10 +0300 | [diff] [blame] | 133 | // Configure repositories |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 134 | allprojects { |
Roman Elizarov | 18fa116 | 2018-06-27 15:13:01 +0300 | [diff] [blame] | 135 | repositories { |
Vsevolod Tolstopyatov | 6f01c93 | 2018-10-23 19:40:48 +0300 | [diff] [blame] | 136 | /* |
| 137 | * google should be first in the repository list because some of the play services |
| 138 | * transitive dependencies was removed from jcenter, thus breaking gradle dependency resolution |
| 139 | */ |
Roman Elizarov | 660c2d7 | 2020-02-14 13:18:37 +0300 | [diff] [blame] | 140 | google() |
Vsevolod Tolstopyatov | ad6211c | 2021-02-10 00:21:58 -0800 | [diff] [blame] | 141 | mavenCentral() |
Roman Elizarov | 18fa116 | 2018-06-27 15:13:01 +0300 | [diff] [blame] | 142 | } |
Roman Elizarov | bf9509d | 2020-02-14 15:52:10 +0300 | [diff] [blame] | 143 | } |
Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 144 | |
Roman Elizarov | bf9509d | 2020-02-14 15:52:10 +0300 | [diff] [blame] | 145 | // Add dependency to core source sets. Core is configured in kx-core/build.gradle |
| 146 | configure(subprojects.findAll { !sourceless.contains(it.name) && it.name != coreModule }) { |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 147 | evaluationDependsOn(":$coreModule") |
Victor Turansky | de38890 | 2020-05-02 14:22:30 +0300 | [diff] [blame] | 148 | def platform = PlatformKt.platformOf(it) |
Vsevolod Tolstopyatov | 0e926e7 | 2021-01-18 08:47:09 -0800 | [diff] [blame] | 149 | apply plugin: "kotlin-${platform}-conventions" |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 150 | dependencies { |
| 151 | // See comment below for rationale, it will be replaced with "project" dependency |
Yahor Berdnikau | a8d55d6 | 2021-03-09 16:38:59 +0100 | [diff] [blame] | 152 | api project(":$coreModule") |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 153 | // the only way IDEA can resolve test classes |
Yahor Berdnikau | a8d55d6 | 2021-03-09 16:38:59 +0100 | [diff] [blame] | 154 | testImplementation project(":$coreModule").kotlin.targets.jvm.compilations.test.output.allOutputs |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 155 | } |
Roman Elizarov | bf9509d | 2020-02-14 15:52:10 +0300 | [diff] [blame] | 156 | } |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 157 | |
Roman Elizarov | bf9509d | 2020-02-14 15:52:10 +0300 | [diff] [blame] | 158 | // Configure subprojects with Kotlin sources |
| 159 | configure(subprojects.findAll { !sourceless.contains(it.name) }) { |
| 160 | // Use atomicfu plugin, it also adds all the necessary dependencies |
| 161 | apply plugin: 'kotlinx-atomicfu' |
| 162 | |
| 163 | // Configure options for all Kotlin compilation tasks |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 164 | tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all { |
Vsevolod Tolstopyatov | f5e8740 | 2021-07-08 13:47:21 +0300 | [diff] [blame] | 165 | kotlinOptions.freeCompilerArgs += optInAnnotations.collect { "-Xopt-in=" + it } |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 166 | kotlinOptions.freeCompilerArgs += "-progressive" |
Vsevolod Tolstopyatov | 556f07a | 2020-12-02 06:52:35 -0800 | [diff] [blame] | 167 | // Disable KT-36770 for RxJava2 integration |
| 168 | kotlinOptions.freeCompilerArgs += "-XXLanguage:-ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated" |
Roman Elizarov | bf9509d | 2020-02-14 15:52:10 +0300 | [diff] [blame] | 169 | // Remove null assertions to get smaller bytecode on Android |
| 170 | kotlinOptions.freeCompilerArgs += ["-Xno-param-assertions", "-Xno-receiver-assertions", "-Xno-call-assertions"] |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 171 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 172 | } |
| 173 | |
Vsevolod Tolstopyatov | 585b766 | 2019-04-16 12:10:57 +0300 | [diff] [blame] | 174 | if (build_snapshot_train) { |
| 175 | println "Hacking test tasks, removing stress and flaky tests" |
| 176 | allprojects { |
| 177 | tasks.withType(Test).all { |
Vsevolod Tolstopyatov | dbe3f48 | 2019-04-17 17:51:13 +0300 | [diff] [blame] | 178 | exclude '**/*LinearizabilityTest*' |
| 179 | exclude '**/*LFTest*' |
| 180 | exclude '**/*StressTest*' |
| 181 | exclude '**/*scheduling*' |
| 182 | exclude '**/*Timeout*' |
Vsevolod Tolstopyatov | 1748ce1 | 2019-04-18 14:49:35 +0300 | [diff] [blame] | 183 | exclude '**/*definitely/not/kotlinx*' |
Vsevolod Tolstopyatov | 642989e | 2020-01-24 20:00:46 +0300 | [diff] [blame] | 184 | // Disable because of KT-11567 in 1.4 |
Vsevolod Tolstopyatov | fb990b0 | 2020-02-04 17:11:47 +0300 | [diff] [blame] | 185 | exclude '**/*CasesPublicAPITest*' |
Sergey Igushkin | 17248c8 | 2020-05-22 12:28:25 +0300 | [diff] [blame] | 186 | // Kotlin |
| 187 | exclude '**/*PrecompiledDebugProbesTest*' |
Vsevolod Tolstopyatov | 1748ce1 | 2019-04-18 14:49:35 +0300 | [diff] [blame] | 188 | } |
| 189 | } |
| 190 | |
| 191 | println "Manifest of kotlin-compiler-embeddable.jar for coroutines" |
| 192 | configure(subprojects.findAll { it.name == "kotlinx-coroutines-core" }) { |
| 193 | configurations.matching { it.name == "kotlinCompilerClasspath" }.all { |
| 194 | resolvedConfiguration.getFiles().findAll { it.name.contains("kotlin-compiler-embeddable") }.each { |
| 195 | def manifest = zipTree(it).matching { |
| 196 | include 'META-INF/MANIFEST.MF' |
| 197 | }.getFiles().first() |
| 198 | |
| 199 | manifest.readLines().each { |
| 200 | println it |
| 201 | } |
| 202 | } |
Vsevolod Tolstopyatov | 585b766 | 2019-04-16 12:10:57 +0300 | [diff] [blame] | 203 | } |
| 204 | } |
| 205 | } |
| 206 | |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 207 | // Redefine source sets because we are not using 'kotlin/main/fqn' folder convention |
Vsevolod Tolstopyatov | fcaa6df | 2020-08-24 18:57:22 +0300 | [diff] [blame] | 208 | configure(subprojects.findAll { |
| 209 | !sourceless.contains(it.name) && |
| 210 | it.name != "benchmarks" && |
| 211 | it.name != coreModule && |
| 212 | it.name != "example-frontend-js" |
| 213 | }) { |
| 214 | // Pure JS and pure MPP doesn't have this notion and are configured separately |
| 215 | // TODO detect it via platformOf and migrate benchmarks to the same scheme |
Vsevolod Tolstopyatov | e1fa197 | 2018-06-19 15:54:58 +0300 | [diff] [blame] | 216 | sourceSets { |
Roman Elizarov | f9408f6 | 2018-06-29 20:12:52 +0300 | [diff] [blame] | 217 | main.kotlin.srcDirs = ['src'] |
| 218 | test.kotlin.srcDirs = ['test'] |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 219 | main.resources.srcDirs = ['resources'] |
| 220 | test.resources.srcDirs = ['test-resources'] |
Vsevolod Tolstopyatov | e1fa197 | 2018-06-19 15:54:58 +0300 | [diff] [blame] | 221 | } |
| 222 | } |
| 223 | |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 224 | def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/$coreModule/" |
Vsevolod Tolstopyatov | bcbcd16 | 2021-07-06 14:29:27 +0300 | [diff] [blame] | 225 | def core_docs_file = "$projectDir/kotlinx-coroutines-core/build/dokka/htmlPartial/package-list" |
| 226 | apply plugin: "org.jetbrains.dokka" |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 227 | |
| 228 | configure(subprojects.findAll { !unpublished.contains(it.name) }) { |
Vsevolod Tolstopyatov | fe4e05c | 2019-07-19 12:28:15 +0300 | [diff] [blame] | 229 | if (it.name != 'kotlinx-coroutines-bom') { |
Vsevolod Tolstopyatov | bcbcd16 | 2021-07-06 14:29:27 +0300 | [diff] [blame] | 230 | apply from: rootProject.file('gradle/dokka.gradle.kts') |
Vsevolod Tolstopyatov | fe4e05c | 2019-07-19 12:28:15 +0300 | [diff] [blame] | 231 | } |
Vsevolod Tolstopyatov | 347feed | 2021-04-22 12:58:39 +0300 | [diff] [blame] | 232 | apply from: rootProject.file('gradle/publish.gradle') |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 233 | } |
| 234 | |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 235 | configure(subprojects.findAll { !unpublished.contains(it.name) }) { |
Vsevolod Tolstopyatov | fe4e05c | 2019-07-19 12:28:15 +0300 | [diff] [blame] | 236 | if (it.name != "kotlinx-coroutines-bom") { |
| 237 | if (it.name != coreModule) { |
Vsevolod Tolstopyatov | bcbcd16 | 2021-07-06 14:29:27 +0300 | [diff] [blame] | 238 | tasks.withType(DokkaTaskPartial.class) { |
| 239 | dokkaSourceSets.configureEach { |
| 240 | externalDocumentationLink { |
| 241 | url.set(new URL(core_docs_url)) |
| 242 | packageListUrl.set(new File(core_docs_file).toURI().toURL()) |
| 243 | } |
Vsevolod Tolstopyatov | fe4e05c | 2019-07-19 12:28:15 +0300 | [diff] [blame] | 244 | } |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 245 | } |
| 246 | } |
Vsevolod Tolstopyatov | e6e8239 | 2018-10-09 19:06:29 +0300 | [diff] [blame] | 247 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 248 | } |
| 249 | |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 250 | // Report Kotlin compiler version when building project |
| 251 | println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION") |
| 252 | |
Roman Elizarov | 85b1a2b | 2020-09-14 17:48:17 +0300 | [diff] [blame] | 253 | // --------------- Cache redirector --------------- |
| 254 | |
| 255 | allprojects { |
| 256 | CacheRedirector.configure(project) |
| 257 | } |
| 258 | |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 259 | // --------------- Configure sub-projects that are published --------------- |
Roman Elizarov | 85b1a2b | 2020-09-14 17:48:17 +0300 | [diff] [blame] | 260 | |
Roman Elizarov | 1ac3dc2 | 2020-02-14 15:39:09 +0300 | [diff] [blame] | 261 | def publishTasks = getTasksByName("publish", true) + getTasksByName("publishNpm", true) |
| 262 | |
Roman Elizarov | 1ac3dc2 | 2020-02-14 15:39:09 +0300 | [diff] [blame] | 263 | task deploy(dependsOn: publishTasks) |
Roman Elizarov | 94fb2a3 | 2018-03-05 17:32:59 +0300 | [diff] [blame] | 264 | |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 265 | apply plugin: 'base' |
| 266 | |
| 267 | clean.dependsOn gradle.includedBuilds.collect { it.task(':clean') } |
Roman Elizarov | 660c2d7 | 2020-02-14 13:18:37 +0300 | [diff] [blame] | 268 | |
| 269 | // --------------- Knit configuration --------------- |
| 270 | |
| 271 | apply plugin: 'kotlinx-knit' |
| 272 | |
| 273 | knit { |
| 274 | siteRoot = "https://kotlin.github.io/kotlinx.coroutines" |
| 275 | moduleRoots = [".", "integration", "reactive", "ui"] |
Vsevolod Tolstopyatov | bcbcd16 | 2021-07-06 14:29:27 +0300 | [diff] [blame] | 276 | moduleDocs = "build/dokka/htmlPartial" |
| 277 | dokkaMultiModuleRoot = "build/dokka/htmlMultiModule/" |
Roman Elizarov | 660c2d7 | 2020-02-14 13:18:37 +0300 | [diff] [blame] | 278 | } |
| 279 | |
Vsevolod Tolstopyatov | bcbcd16 | 2021-07-06 14:29:27 +0300 | [diff] [blame] | 280 | knitPrepare.dependsOn getTasksByName("dokkaHtmlMultiModule", true) |
| 281 | |
| 282 | dependencies { |
| 283 | dokkaHtmlMultiModulePlugin("org.jetbrains.kotlinx:dokka-pathsaver-plugin:$knit_version") |
| 284 | } |
Alexander Likhachev | 179f142 | 2020-11-18 17:54:33 +0300 | [diff] [blame] | 285 | |
Vsevolod Tolstopyatov | 1392686 | 2021-06-07 16:24:21 +0300 | [diff] [blame] | 286 | // Opt-in for build scan in order to troubleshoot Gradle on TC |
| 287 | if (hasProperty('buildScan')) { |
| 288 | buildScan { |
| 289 | termsOfServiceUrl = 'https://gradle.com/terms-of-service' |
| 290 | termsOfServiceAgree = 'yes' |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | /* |
| 295 | * kotlinx-coroutines-core dependency leaks into test runtime classpath via kotlin-compiler-embeddable |
| 296 | * and conflicts with our own test/runtime incompatibilities (e.g. when class is moved from a main to test), |
| 297 | * so we do substitution here |
| 298 | */ |
| 299 | allprojects { subProject -> |
| 300 | subProject |
| 301 | .configurations |
| 302 | .matching { |
| 303 | // Excluding substituted project itself because of circular dependencies, but still do it |
| 304 | // for "*Test*" configurations |
| 305 | subProject.name != "kotlinx-coroutines-core" || it.name.contains("Test") |
| 306 | } |
| 307 | .configureEach { conf -> |
| 308 | conf.resolutionStrategy.dependencySubstitution { |
| 309 | substitute(module("org.jetbrains.kotlinx:kotlinx-coroutines-core")) |
| 310 | .using(project(":kotlinx-coroutines-core")) |
| 311 | .because("Because Kotlin compiler embeddable leaks coroutines into the runtime classpath, " + |
| 312 | "triggering all sort of incompatible class changes errors") |
| 313 | } |
| 314 | } |
| 315 | } |