blob: a6e81b7cbbc4fa1d17e2a46e726fe6eac41af338 [file] [log] [blame]
Roman Elizarov1f74a2d2018-06-29 19:19:45 +03001/*
2 * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4
Kirill Timofeeva5186962017-10-25 14:25:47 +03005buildscript {
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +03006 ext.useKotlinSnapshot = rootProject.properties['kotlinSnapshot'] != null
7 if (useKotlinSnapshot) {
Roman Elizarovdadd50c2017-12-21 17:34:12 +03008 ext.kotlin_version = '1.2-SNAPSHOT'
Roman Elizarov1f6b44d2017-10-26 17:51:52 +03009 repositories {
10 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
11 }
12 }
Kirill Timofeeva5186962017-10-25 14:25:47 +030013 repositories {
14 jcenter()
Vsevolod Tolstopyatovce5d01a2019-01-23 17:41:02 +030015 maven { url "https://teamcity.jetbrains.com/guestAuth/app/rest/builds/id:1907319/artifacts/content/maven" }
Roman Elizarov31452902018-04-11 13:58:19 +030016 maven { url "https://kotlin.bintray.com/kotlinx" }
17 maven { url "https://kotlin.bintray.com/kotlin-dev" }
Roman Elizarov0950dfa2018-07-13 10:33:25 +030018 maven { url "https://kotlin.bintray.com/kotlin-eap" }
Roman Elizarov31452902018-04-11 13:58:19 +030019 maven { url "https://jetbrains.bintray.com/kotlin-native-dependencies" }
Roman Elizarov65eff0b2017-12-20 15:51:31 +030020 maven { url "https://plugins.gradle.org/m2/" }
Kirill Timofeeva5186962017-10-25 14:25:47 +030021 }
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030022 configurations.classpath {
23 resolutionStrategy {
24 eachDependency { DependencyResolveDetails details ->
25 if (details.requested.group == 'org.jetbrains.kotlin' && details.requested.name != 'kotlin-native-gradle-plugin') {
26 // fix version of all dependencies from org.jetbrains.kotlin group
27 // even when other dependencies require other versions indirectly,
28 // except kotlin-native, which has its own pre-release versioning
29 details.useVersion kotlin_version
30 }
31 }
32 }
33 }
Kirill Timofeeva5186962017-10-25 14:25:47 +030034 dependencies {
Vsevolod Tolstopyatov31796832018-11-12 14:49:41 +030035 classpath "org.jfrog.buildinfo:build-info-extractor-gradle:$artifactory_plugin_version"
Kirill Timofeeva5186962017-10-25 14:25:47 +030036 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Roman Elizarov31452902018-04-11 13:58:19 +030037 classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version"
Kirill Timofeeva5186962017-10-25 14:25:47 +030038 classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
39 classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version"
Roman Elizarov65eff0b2017-12-20 15:51:31 +030040 classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version"
41 classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
Vsevolod Tolstopyatov305c66a2018-08-21 21:01:58 +030042
43 // JMH plugins
Vsevolod Tolstopyatov3781a822018-12-13 11:58:29 +030044 classpath "com.github.jengelman.gradle.plugins:shadow:4.0.2"
Vsevolod Tolstopyatov305c66a2018-08-21 21:01:58 +030045 classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.7"
46 classpath "net.ltgt.gradle:gradle-apt-plugin:0.10"
Kirill Timofeeva5186962017-10-25 14:25:47 +030047 }
48}
49
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030050allprojects {
51 def deployVersion = properties['DeployVersion']
52 if (deployVersion != null) version = deployVersion
53 if (useKotlinSnapshot) {
54 kotlin_version = '1.2-SNAPSHOT'
55 }
Roman Elizarov18fa1162018-06-27 15:13:01 +030056
Vsevolod Tolstopyatov6f01c932018-10-23 19:40:48 +030057 def name = it.name
Roman Elizarov18fa1162018-06-27 15:13:01 +030058 repositories {
Vsevolod Tolstopyatov6f01c932018-10-23 19:40:48 +030059 /*
60 * google should be first in the repository list because some of the play services
61 * transitive dependencies was removed from jcenter, thus breaking gradle dependency resolution
62 */
63 if (name == "kotlinx-coroutines-play-services") {
64 google()
65 }
Roman Elizarov18fa1162018-06-27 15:13:01 +030066 jcenter()
Vsevolod Tolstopyatovce5d01a2019-01-23 17:41:02 +030067 maven { url "https://teamcity.jetbrains.com/guestAuth/app/rest/builds/id:1907319/artifacts/content/maven" }
Vsevolod Tolstopyatov8a45c472018-10-24 11:55:30 +030068 maven { url "https://kotlin.bintray.com/kotlin-dev" }
Roman Elizarov0950dfa2018-07-13 10:33:25 +030069 maven { url "https://kotlin.bintray.com/kotlin-eap" }
Roman Elizarov18fa1162018-06-27 15:13:01 +030070 maven { url "https://kotlin.bintray.com/kotlinx" }
71 }
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030072}
73
74
Roman Elizarov38b6fd32018-01-17 10:12:23 +030075// Report Kotlin compiler version when building project
76println("Using Kotlin compiler version: $org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION")
77
Kirill Timofeeva5186962017-10-25 14:25:47 +030078// --------------- Configure sub-projects with Kotlin sources ---------------
79
80def sourceless = ['site']
81
Roman Elizarove1c0b652017-12-01 14:02:57 +030082static def platformOf(project) {
83 if (project.name.endsWith("-common")) return "common"
84 if (project.name.endsWith("-js")) return "js"
Roman Elizarov31452902018-04-11 13:58:19 +030085 if (project.name.endsWith("-native")) return "native"
Roman Elizarove1c0b652017-12-01 14:02:57 +030086 return "jvm"
87}
Kirill Timofeeva5186962017-10-25 14:25:47 +030088
Roman Elizarove1c0b652017-12-01 14:02:57 +030089static def platformLib(base, platform) {
90 if (platform == "jvm") return base
91 return "$base-$platform"
92}
93
Ilya Gorbunovb1a07ee2018-04-16 21:51:55 +030094subprojects {
95 if (useKotlinSnapshot) {
96 repositories {
97 maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
98 }
99 }
100 configurations.all {
101 resolutionStrategy {
102 eachDependency { DependencyResolveDetails details ->
103 if (details.requested.group == 'org.jetbrains.kotlin') {
104 details.useVersion kotlin_version
105 }
106 }
107 }
108 }
109}
110
Roman Elizarove1c0b652017-12-01 14:02:57 +0300111configure(subprojects.findAll { !sourceless.contains(it.name) }) {
112 def platform = platformOf(it)
Roman Elizarove1a56522018-04-04 10:31:08 +0300113 apply from: rootProject.file("gradle/compile-${platform}.gradle")
Kirill Timofeeva5186962017-10-25 14:25:47 +0300114}
115
116// --------------- Configure sub-projects that are part of the library ---------------
117
Vsevolod Tolstopyatov706e3932018-10-13 15:40:32 +0300118def internal = sourceless + ['benchmarks', 'knit', 'js-stub', 'stdlib-stubs', 'binary-compatibility-validator']
Kirill Timofeeva5186962017-10-25 14:25:47 +0300119
Vsevolod Tolstopyatove1fa1972018-06-19 15:54:58 +0300120// Reconfigure source sets to avoid long "src/main/kotlin/fqn"
121configure(subprojects.findAll { !it.name.contains(sourceless) && it.name != "benchmarks" }) {
Vsevolod Tolstopyatov4ddfc912018-07-12 18:36:02 +0300122 def projectName = it.name
Vsevolod Tolstopyatove1fa1972018-06-19 15:54:58 +0300123 sourceSets {
Roman Elizarovf9408f62018-06-29 20:12:52 +0300124 main.kotlin.srcDirs = ['src']
125 test.kotlin.srcDirs = ['test']
Roman Elizarov7587eba2018-07-25 12:22:46 +0300126 // todo: do we still need this workaround?
Vsevolod Tolstopyatov4ddfc912018-07-12 18:36:02 +0300127 if (!projectName.endsWith("-native")) {
128 main.resources.srcDirs = ['resources']
Roman Elizarov7587eba2018-07-25 12:22:46 +0300129 test.resources.srcDirs = ['test-resources']
Vsevolod Tolstopyatov4ddfc912018-07-12 18:36:02 +0300130 }
Vsevolod Tolstopyatove1fa1972018-06-19 15:54:58 +0300131 }
132}
133
Roman Elizarov31452902018-04-11 13:58:19 +0300134// configure atomicfu
135configure(subprojects.findAll { !internal.contains(it.name) }) {
136 def platform = platformOf(it)
137 apply from: rootProject.file("gradle/atomicfu-${platform}.gradle")
Kirill Timofeeva5186962017-10-25 14:25:47 +0300138}
139
Roman Elizarove1c0b652017-12-01 14:02:57 +0300140// configure dependencies on core
141configure(subprojects.findAll { !internal.contains(it.name) && it.name != 'kotlinx-coroutines-core-common'}) {
142 def platform = platformOf(it)
143 def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
144
145 if (it.name == coroutines_core) {
146 dependencies {
147 expectedBy project(':kotlinx-coroutines-core-common')
148 }
149 } else {
150 dependencies {
151 compile project(":$coroutines_core")
152 //the only way IDEA can resolve test classes
153 testCompile project(":$coroutines_core").sourceSets.test.output
154 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300155 }
156}
157
158// --------------- Configure sub-projects that are published ---------------
159
Vsevolod Tolstopyatov4327b212018-12-17 19:49:12 +0300160def unpublished = internal + ['kotlinx-coroutines-rx-example', 'example-frontend-js', 'android-unit-tests']
Kirill Timofeeva5186962017-10-25 14:25:47 +0300161
162def core_docs_url = "https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/"
163def core_docs_file = "$projectDir/core/kotlinx-coroutines-core/build/dokka/kotlinx-coroutines-core/package-list"
164
165configure(subprojects.findAll { !unpublished.contains(it.name) }) {
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300166 apply from: rootProject.file('gradle/dokka.gradle')
167 apply from: rootProject.file('gradle/publish-bintray.gradle')
Kirill Timofeeva5186962017-10-25 14:25:47 +0300168}
169
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300170configure(subprojects.findAll { !unpublished.contains(it.name) }) {
Roman Elizarove1c0b652017-12-01 14:02:57 +0300171 def platform = platformOf(it)
172 def coroutines_core = platformLib("kotlinx-coroutines-core", platform)
173
Roman Elizarov65eff0b2017-12-20 15:51:31 +0300174 if (it.name != coroutines_core) {
175 dokka.dependsOn project(":$coroutines_core").dokka
176
177 tasks.withType(dokka.getClass()) {
178 externalDocumentationLink {
179 url = new URL(core_docs_url)
180 packageListUrl = new URL("file://$core_docs_file")
181 }
182 }
183 }
Vsevolod Tolstopyatove6e82392018-10-09 19:06:29 +0300184
Roman Elizarove1c0b652017-12-01 14:02:57 +0300185 if (platform == "jvm") {
186 dokkaJavadoc.dependsOn project(":$coroutines_core").dokka
Roman Elizarovaa100ea2018-08-22 11:21:53 +0300187 // dump declarations from main JVM module for binary-compatibility-validator
188 compileKotlin {
Vsevolod Tolstopyatov74bcc922018-05-03 20:07:54 +0300189 kotlinOptions.freeCompilerArgs += ["-Xdump-declarations-to=${buildDir}/visibilities.json"]
190 }
Roman Elizarove1c0b652017-12-01 14:02:57 +0300191 }
Vsevolod Tolstopyatove6e82392018-10-09 19:06:29 +0300192
193
194 tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all {
195 kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlin.Experimental",
196 "-Xuse-experimental=kotlin.experimental.ExperimentalTypeInference",
Vsevolod Tolstopyatov06600a22018-11-13 13:47:27 +0300197 "-Xuse-experimental=kotlin.ExperimentalMultiplatform",
Vsevolod Tolstopyatove6e82392018-10-09 19:06:29 +0300198 "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
199 "-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi",
Vsevolod Tolstopyatovd88e4272018-11-27 14:19:31 +0300200 "-Xuse-experimental=kotlinx.coroutines.InternalCoroutinesApi",
201 "-progressive"]
Vsevolod Tolstopyatove6e82392018-10-09 19:06:29 +0300202 }
Kirill Timofeeva5186962017-10-25 14:25:47 +0300203}
204
Roman Elizarov94fb2a32018-03-05 17:32:59 +0300205// main deployment task
206task deploy(dependsOn: getTasksByName("bintrayUpload", true) + getTasksByName("publishNpm", true))
207
Kirill Timofeeva5186962017-10-25 14:25:47 +0300208apply plugin: 'base'
209
210clean.dependsOn gradle.includedBuilds.collect { it.task(':clean') }