Roman Elizarov | 1f74a2d | 2018-06-29 19:19:45 +0300 | [diff] [blame] | 1 | /* |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 2 | * Copyright 2016-2019 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 | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 4 | import org.jetbrains.kotlin.konan.target.HostManager |
| 5 | |
| 6 | apply from: rootProject.file("gradle/experimental.gradle") |
| 7 | |
| 8 | def rootModule = "kotlinx.coroutines" |
| 9 | def coreModule = "kotlinx-coroutines-core" |
| 10 | // Not applicable for Kotlin plugin |
| 11 | def sourceless = ['kotlinx.coroutines', 'site'] |
| 12 | def internal = sourceless + ['benchmarks', 'knit', 'js-stub', 'stdlib-stubs', 'binary-compatibility-validator'] |
| 13 | // Not published |
| 14 | def unpublished = internal + ['kotlinx-coroutines-rx-example', 'example-frontend-js', 'android-unit-tests'] |
| 15 | |
| 16 | static def platformOf(project) { |
| 17 | def name = project.name |
| 18 | if (name.endsWith("-js")) return "js" |
| 19 | if (name.endsWith("-common") || name.endsWith("-native")) { |
| 20 | throw IllegalStateException("$name platform is not supported") |
| 21 | } |
| 22 | return "jvm" |
| 23 | } |
Roman Elizarov | 1f74a2d | 2018-06-29 19:19:45 +0300 | [diff] [blame] | 24 | |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 25 | buildscript { |
Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 26 | ext.useKotlinSnapshot = rootProject.properties['kotlinSnapshot'] != null |
| 27 | if (useKotlinSnapshot) { |
Roman Elizarov | dadd50c | 2017-12-21 17:34:12 +0300 | [diff] [blame] | 28 | ext.kotlin_version = '1.2-SNAPSHOT' |
Roman Elizarov | 1f6b44d | 2017-10-26 17:51:52 +0300 | [diff] [blame] | 29 | repositories { |
| 30 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" } |
| 31 | } |
| 32 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 33 | repositories { |
| 34 | jcenter() |
Roman Elizarov | 3145290 | 2018-04-11 13:58:19 +0300 | [diff] [blame] | 35 | maven { url "https://kotlin.bintray.com/kotlinx" } |
| 36 | maven { url "https://kotlin.bintray.com/kotlin-dev" } |
Roman Elizarov | 0950dfa | 2018-07-13 10:33:25 +0300 | [diff] [blame] | 37 | maven { url "https://kotlin.bintray.com/kotlin-eap" } |
Roman Elizarov | 3145290 | 2018-04-11 13:58:19 +0300 | [diff] [blame] | 38 | maven { url "https://jetbrains.bintray.com/kotlin-native-dependencies" } |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 39 | maven { url "https://plugins.gradle.org/m2/" } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 40 | } |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 41 | |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 42 | dependencies { |
Vsevolod Tolstopyatov | 3179683 | 2018-11-12 14:49:41 +0300 | [diff] [blame] | 43 | classpath "org.jfrog.buildinfo:build-info-extractor-gradle:$artifactory_plugin_version" |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 44 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" |
| 45 | classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" |
| 46 | classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version" |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 47 | classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version" |
| 48 | classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version" |
Vsevolod Tolstopyatov | 305c66a | 2018-08-21 21:01:58 +0300 | [diff] [blame] | 49 | |
| 50 | // JMH plugins |
Vsevolod Tolstopyatov | 3781a82 | 2018-12-13 11:58:29 +0300 | [diff] [blame] | 51 | classpath "com.github.jengelman.gradle.plugins:shadow:4.0.2" |
Vsevolod Tolstopyatov | 305c66a | 2018-08-21 21:01:58 +0300 | [diff] [blame] | 52 | classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.7" |
| 53 | classpath "net.ltgt.gradle:gradle-apt-plugin:0.10" |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 54 | } |
| 55 | } |
| 56 | |
Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 57 | allprojects { |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 58 | // the only place where HostManager could be instantiated |
| 59 | project.ext.hostManager = new HostManager() |
| 60 | } |
| 61 | |
| 62 | allprojects { |
| 63 | apply plugin: 'kotlinx-atomicfu' |
| 64 | |
Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 65 | def deployVersion = properties['DeployVersion'] |
| 66 | if (deployVersion != null) version = deployVersion |
| 67 | if (useKotlinSnapshot) { |
| 68 | kotlin_version = '1.2-SNAPSHOT' |
| 69 | } |
Roman Elizarov | 18fa116 | 2018-06-27 15:13:01 +0300 | [diff] [blame] | 70 | |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 71 | def projectName = it.name |
Roman Elizarov | 18fa116 | 2018-06-27 15:13:01 +0300 | [diff] [blame] | 72 | repositories { |
Vsevolod Tolstopyatov | 6f01c93 | 2018-10-23 19:40:48 +0300 | [diff] [blame] | 73 | /* |
| 74 | * google should be first in the repository list because some of the play services |
| 75 | * transitive dependencies was removed from jcenter, thus breaking gradle dependency resolution |
| 76 | */ |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 77 | if (projectName == "kotlinx-coroutines-play-services") { |
Vsevolod Tolstopyatov | 6f01c93 | 2018-10-23 19:40:48 +0300 | [diff] [blame] | 78 | google() |
| 79 | } |
Roman Elizarov | 18fa116 | 2018-06-27 15:13:01 +0300 | [diff] [blame] | 80 | jcenter() |
Vsevolod Tolstopyatov | 8a45c47 | 2018-10-24 11:55:30 +0300 | [diff] [blame] | 81 | maven { url "https://kotlin.bintray.com/kotlin-dev" } |
Roman Elizarov | 0950dfa | 2018-07-13 10:33:25 +0300 | [diff] [blame] | 82 | maven { url "https://kotlin.bintray.com/kotlin-eap" } |
Roman Elizarov | 18fa116 | 2018-06-27 15:13:01 +0300 | [diff] [blame] | 83 | maven { url "https://kotlin.bintray.com/kotlinx" } |
| 84 | } |
Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 85 | |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 86 | if (projectName == rootModule || projectName == coreModule) return |
Ilya Gorbunov | b1a07ee | 2018-04-16 21:51:55 +0300 | [diff] [blame] | 87 | |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 88 | // Add dependency to core source sets. Core is configured in kx-core/build.gradle |
| 89 | evaluationDependsOn(":$coreModule") |
| 90 | if (sourceless.contains(projectName)) return |
Roman Elizarov | 38b6fd3 | 2018-01-17 10:12:23 +0300 | [diff] [blame] | 91 | |
Roman Elizarov | e1c0b65 | 2017-12-01 14:02:57 +0300 | [diff] [blame] | 92 | def platform = platformOf(it) |
Roman Elizarov | e1a5652 | 2018-04-04 10:31:08 +0300 | [diff] [blame] | 93 | apply from: rootProject.file("gradle/compile-${platform}.gradle") |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 94 | |
| 95 | |
| 96 | dependencies { |
| 97 | // See comment below for rationale, it will be replaced with "project" dependency |
| 98 | compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version" |
| 99 | compileOnly "org.jetbrains.kotlinx:atomicfu:$atomicFU_version" |
| 100 | |
| 101 | // the only way IDEA can resolve test classes |
| 102 | testCompile project(":$coreModule").kotlin.targets.jvm.compilations.test.output.allOutputs |
| 103 | } |
| 104 | |
| 105 | tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all { |
| 106 | kotlinOptions.freeCompilerArgs += experimentalAnnotations.collect { "-Xuse-experimental=" + it } |
| 107 | kotlinOptions.freeCompilerArgs += "-progressive" |
| 108 | // Binary compatibility support |
| 109 | kotlinOptions.freeCompilerArgs += ["-Xdump-declarations-to=${buildDir}/visibilities.json"] |
| 110 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 111 | } |
| 112 | |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 113 | /* |
| 114 | * Hack to trick nmpp plugin: we are renaming artifacts in order to provide backward compatibility for dependencies, |
| 115 | * but publishing plugin does not re-read artifact names for kotlin-jvm projects, so renaming is not applied in pom files |
| 116 | * for JVM-only projects. |
| 117 | * |
| 118 | * We artificially replace "project" dependency with "module" one to have proper names in pom files, but then substitute it |
| 119 | * to have out "project" dependency back. |
| 120 | */ |
| 121 | configure(subprojects.findAll { it.name != coreModule && it.name != rootModule }) { |
| 122 | configurations.all { |
| 123 | resolutionStrategy.dependencySubstitution { |
| 124 | substitute module("org.jetbrains.kotlinx:kotlinx-coroutines-core:$version") with project(':kotlinx-coroutines-core') |
| 125 | } |
| 126 | } |
| 127 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 128 | |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 129 | // Redefine source sets because we are not using 'kotlin/main/fqn' folder convention |
| 130 | configure(subprojects.findAll { !sourceless.contains(it.name) && it.name != "benchmarks" && it.name != coreModule }) { |
Vsevolod Tolstopyatov | e1fa197 | 2018-06-19 15:54:58 +0300 | [diff] [blame] | 131 | sourceSets { |
Roman Elizarov | f9408f6 | 2018-06-29 20:12:52 +0300 | [diff] [blame] | 132 | main.kotlin.srcDirs = ['src'] |
| 133 | test.kotlin.srcDirs = ['test'] |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 134 | main.resources.srcDirs = ['resources'] |
| 135 | test.resources.srcDirs = ['test-resources'] |
Vsevolod Tolstopyatov | e1fa197 | 2018-06-19 15:54:58 +0300 | [diff] [blame] | 136 | } |
| 137 | } |
| 138 | |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 139 | def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/$coreModule/" |
| 140 | def core_docs_file = "$projectDir/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list" |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 141 | |
| 142 | configure(subprojects.findAll { !unpublished.contains(it.name) }) { |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 143 | apply from: rootProject.file('gradle/dokka.gradle') |
| 144 | apply from: rootProject.file('gradle/publish-bintray.gradle') |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 145 | } |
| 146 | |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 147 | configure(subprojects.findAll { !unpublished.contains(it.name) }) { |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 148 | if (it.name != coreModule) { |
| 149 | dokka.dependsOn project(":$coreModule").dokka |
Roman Elizarov | 65eff0b | 2017-12-20 15:51:31 +0300 | [diff] [blame] | 150 | tasks.withType(dokka.getClass()) { |
| 151 | externalDocumentationLink { |
| 152 | url = new URL(core_docs_url) |
| 153 | packageListUrl = new URL("file://$core_docs_file") |
| 154 | } |
| 155 | } |
| 156 | } |
Vsevolod Tolstopyatov | e6e8239 | 2018-10-09 19:06:29 +0300 | [diff] [blame] | 157 | |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 158 | if (platformOf(it) == "jvm") { |
| 159 | dokkaJavadoc.dependsOn project(":$coreModule").dokka |
Vsevolod Tolstopyatov | e6e8239 | 2018-10-09 19:06:29 +0300 | [diff] [blame] | 160 | } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 161 | } |
| 162 | |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 163 | |
| 164 | // Report Kotlin compiler version when building project |
| 165 | println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION") |
| 166 | |
| 167 | // --------------- Configure sub-projects that are published --------------- |
Roman Elizarov | 94fb2a3 | 2018-03-05 17:32:59 +0300 | [diff] [blame] | 168 | task deploy(dependsOn: getTasksByName("bintrayUpload", true) + getTasksByName("publishNpm", true)) |
| 169 | |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 170 | apply plugin: 'base' |
| 171 | |
| 172 | clean.dependsOn gradle.includedBuilds.collect { it.task(':clean') } |