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